@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.
@@ -1078,6 +1078,60 @@ var AUTH_SURFACE_OPERATIONS = [
1078
1078
  responseType: "RevokeAllKeysResponse",
1079
1079
  summary: "Revokes every key the caller has, sparing the calling device unless asked otherwise.",
1080
1080
  since: "0.4.1"
1081
+ },
1082
+ {
1083
+ id: "auth.device.start",
1084
+ method: "POST",
1085
+ path: "/_auth/device/start",
1086
+ authProfile: "none",
1087
+ requiresSession: false,
1088
+ requestType: "StartDeviceAuthRequest",
1089
+ responseType: "StartDeviceAuthResponse",
1090
+ summary: "Parks a new device's public key and returns the codes it shows and polls with.",
1091
+ since: "0.10.0"
1092
+ },
1093
+ {
1094
+ id: "auth.device.poll",
1095
+ method: "POST",
1096
+ path: "/_auth/device/poll",
1097
+ authProfile: "none",
1098
+ requiresSession: false,
1099
+ requestType: "PollDeviceAuthRequest",
1100
+ responseType: "PollDeviceAuthResponse",
1101
+ summary: "Asks whether the request has been answered; the approved answer is the login it produced.",
1102
+ since: "0.10.0"
1103
+ },
1104
+ {
1105
+ id: "auth.device.info",
1106
+ method: "POST",
1107
+ path: "/_auth/device/info",
1108
+ authProfile: "clientProofV1",
1109
+ requiresSession: false,
1110
+ requestType: "DeviceAuthInfoRequest",
1111
+ responseType: "DeviceAuthInfoResponse",
1112
+ summary: "Describes the device waiting on a user code, so the approver can recognise it before deciding.",
1113
+ since: "0.10.0"
1114
+ },
1115
+ {
1116
+ id: "auth.device.approve",
1117
+ method: "POST",
1118
+ path: "/_auth/device/approve",
1119
+ authProfile: "clientProofV1",
1120
+ requiresSession: false,
1121
+ requestType: "ApproveDeviceAuthRequest",
1122
+ responseType: "DeviceAuthInfoResponse",
1123
+ summary: "Lets the waiting device in, answering with the device it just let in.",
1124
+ since: "0.10.0"
1125
+ },
1126
+ {
1127
+ id: "auth.device.deny",
1128
+ method: "POST",
1129
+ path: "/_auth/device/deny",
1130
+ authProfile: "clientProofV1",
1131
+ requiresSession: false,
1132
+ requestType: "DenyDeviceAuthRequest",
1133
+ summary: "Refuses the waiting device. Answers 204 with no body, so it names no response type.",
1134
+ since: "0.10.0"
1081
1135
  }
1082
1136
  ];
1083
1137
  var ContractTypeError = class extends Error {
@@ -1325,6 +1379,7 @@ import {
1325
1379
 
1326
1380
  // src/server/types.ts
1327
1381
  var KEY_ALGORITHM = ["ES256", "RS256"];
1382
+ var KEY_PLATFORM = ["ios", "android", "web", "desktop"];
1328
1383
 
1329
1384
  // src/server/client-proof/wire-headers.ts
1330
1385
  var CLIENT_IDENTITY_HEADERS = {
@@ -1342,9 +1397,9 @@ function isAppKind(kind) {
1342
1397
  }
1343
1398
 
1344
1399
  // src/server/client-proof/contract-bundle.ts
1345
- var CONTRACT_VERSION = "0.9.0";
1400
+ var CONTRACT_VERSION = "0.10.0";
1346
1401
  var CONTRACT_MAJOR = 0;
1347
- var CONTRACT_SUPPORTED_RANGE = ">=0.9.0 <0.10.0";
1402
+ var CONTRACT_SUPPORTED_RANGE = ">=0.10.0 <0.11.0";
1348
1403
  function required(name, type) {
1349
1404
  return { name, type, optional: false };
1350
1405
  }
@@ -1515,7 +1570,7 @@ var CONTRACT_TYPES = [
1515
1570
  fields: [
1516
1571
  required("keyId", "string"),
1517
1572
  optional("deviceName", "string"),
1518
- optional("platform", "string"),
1573
+ optional("platform", "KeyPlatform"),
1519
1574
  required("algorithm", "KeyAlgorithm"),
1520
1575
  required("fingerprintPrefix", "string"),
1521
1576
  required("createdAtMillis", "integer"),
@@ -1557,10 +1612,94 @@ var CONTRACT_TYPES = [
1557
1612
  required("revokedCount", "integer"),
1558
1613
  required("currentKeyRevoked", "boolean")
1559
1614
  ]
1615
+ },
1616
+ {
1617
+ name: "StartDeviceAuthRequest",
1618
+ fields: [
1619
+ required("publicKey", "string"),
1620
+ required("keyId", "string"),
1621
+ required("fingerprint", "string"),
1622
+ optional("algorithm", "KeyAlgorithm"),
1623
+ optional("deviceName", "string"),
1624
+ optional("platform", "KeyPlatform")
1625
+ ]
1626
+ },
1627
+ {
1628
+ name: "StartDeviceAuthResponse",
1629
+ fields: [
1630
+ required("deviceCode", "string"),
1631
+ required("userCode", "string"),
1632
+ required("expiresAtMillis", "integer"),
1633
+ required("intervalMillis", "integer")
1634
+ ]
1635
+ },
1636
+ {
1637
+ name: "PollDeviceAuthRequest",
1638
+ fields: [
1639
+ required("deviceCode", "string")
1640
+ ]
1641
+ },
1642
+ /**
1643
+ * The poll union, flattened into the one shape this grammar can carry.
1644
+ *
1645
+ * `status` is the discriminant and the only required field; everything else
1646
+ * belongs to one branch and is therefore optional. `intervalMillis` is the
1647
+ * pending branch, and the five after it are the approved branch — the same
1648
+ * fields `LoginResponse` carries, because an approved poll is the login the
1649
+ * approval produced. `deviceAuthorization.pollStatusRule` states the pairing
1650
+ * the grammar cannot.
1651
+ */
1652
+ {
1653
+ name: "PollDeviceAuthResponse",
1654
+ fields: [
1655
+ required("status", "DeviceAuthPollStatus"),
1656
+ optional("intervalMillis", "integer"),
1657
+ optional("userId", "string"),
1658
+ optional("publicId", "string"),
1659
+ optional("email", "string"),
1660
+ optional("phone", "string"),
1661
+ optional("passwordChangeRequired", "boolean")
1662
+ ]
1663
+ },
1664
+ /**
1665
+ * Info, approve and deny each declare their own request type although all
1666
+ * three carry nothing but `userCode`. An operation's request shape is its
1667
+ * own: a field added to one of them later must not appear on the other two
1668
+ * by accident, which is what a shared type would do.
1669
+ */
1670
+ {
1671
+ name: "DeviceAuthInfoRequest",
1672
+ fields: [
1673
+ required("userCode", "string")
1674
+ ]
1675
+ },
1676
+ {
1677
+ name: "DeviceAuthInfoResponse",
1678
+ fields: [
1679
+ optional("deviceName", "string"),
1680
+ optional("platform", "KeyPlatform"),
1681
+ required("fingerprintPrefix", "string"),
1682
+ required("requestedAtMillis", "integer"),
1683
+ required("expiresAtMillis", "integer")
1684
+ ]
1685
+ },
1686
+ {
1687
+ name: "ApproveDeviceAuthRequest",
1688
+ fields: [
1689
+ required("userCode", "string")
1690
+ ]
1691
+ },
1692
+ {
1693
+ name: "DenyDeviceAuthRequest",
1694
+ fields: [
1695
+ required("userCode", "string")
1696
+ ]
1560
1697
  }
1561
1698
  ];
1562
1699
  var CONTRACT_ENUMS = [
1563
- { name: "KeyAlgorithm", values: [...KEY_ALGORITHM] }
1700
+ { name: "KeyAlgorithm", values: [...KEY_ALGORITHM] },
1701
+ { name: "KeyPlatform", values: [...KEY_PLATFORM] },
1702
+ { name: "DeviceAuthPollStatus", values: ["pending", "approved"] }
1564
1703
  ];
1565
1704
  var BUNDLE_FILENAME = "spfn-mobile-contract.json";
1566
1705
  var BUNDLE_REPO_PATH = `contracts/mobile/${BUNDLE_FILENAME}`;