@oxy.so/contracts 6.12.0 → 6.13.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/dist/cjs/appAssertions.js +31 -2
- package/dist/cjs/client/appAssertions.js +10 -2
- package/dist/cjs/client/index.js +8 -1
- package/dist/cjs/client/platformSession.js +61 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/platformSession.js +104 -0
- package/dist/cjs/signIn.js +12 -2
- package/dist/esm/appAssertions.js +30 -1
- package/dist/esm/client/appAssertions.js +10 -2
- package/dist/esm/client/index.js +1 -0
- package/dist/esm/client/platformSession.js +58 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/platformSession.js +97 -0
- package/dist/esm/signIn.js +12 -2
- package/dist/types/appAssertions.d.ts +40 -1
- package/dist/types/client/appAssertions.d.ts +11 -4
- package/dist/types/client/index.d.ts +2 -0
- package/dist/types/client/platformSession.d.ts +50 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/inference/embeddings.d.ts +4 -4
- package/dist/types/inference/errors.d.ts +4 -4
- package/dist/types/inference/inbox.d.ts +2 -2
- package/dist/types/inference/realtime.d.ts +4 -4
- package/dist/types/inference/streamEvents.d.ts +4 -4
- package/dist/types/oxyRecordTypes.d.ts +1 -1
- package/dist/types/platformSession.d.ts +129 -0
- package/dist/types/signIn.d.ts +23 -2
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.appAssertionResponseSchema = exports.appAssertionRequestSchema = exports.appAttestKeyResponseSchema = exports.appAttestKeyRequestSchema = exports.appAttestKeyIdSchema = exports.appAssertionChallengeResponseSchema = exports.appAssertionChallengeRequestSchema = exports.applicationRecognitionSchema = exports.applicationRecognitionWriteSchema = exports.applicationIosRecognitionSchema = exports.applicationAndroidRecognitionSchema = exports.appleBundleIdSchema = exports.appleTeamIdSchema = exports.signingCertSha256Schema = exports.androidPackageNameSchema = exports.applicationWebOriginSchema = exports.appAssertionErrorCodeSchema = exports.appAssertionPlatformSchema = exports.OXY_APP_ASSERTION_TYPE = exports.OXY_APP_ASSERTION_TTL_SECONDS = exports.OXY_APP_ASSERTION_HEADER = exports.OXY_APP_ASSERTION_AUDIENCE = exports.APP_ASSERTION_PLATFORMS = exports.APP_ASSERTION_ERROR_CODES = exports.APP_ASSERTION_CHALLENGE_PURPOSES = void 0;
|
|
3
|
+
exports.appAssertionResponseSchema = exports.appAssertionRequestSchema = exports.appAttestKeyResponseSchema = exports.appAttestKeyRequestSchema = exports.appAttestKeyIdSchema = exports.appAssertionChallengeResponseSchema = exports.appAssertionChallengeRequestSchema = exports.applicationRecognitionSchema = exports.applicationRecognitionWriteSchema = exports.applicationIosRecognitionSchema = exports.applicationAndroidRecognitionSchema = exports.oxyosDesktopEntryIdSchema = exports.appleBundleIdSchema = exports.appleTeamIdSchema = exports.signingCertSha256Schema = exports.androidPackageNameSchema = exports.applicationWebOriginSchema = exports.appAssertionErrorCodeSchema = exports.platformHostSchema = exports.appAssertionPlatformSchema = exports.OXY_APP_ASSERTION_TYPE = exports.OXY_APP_ASSERTION_TTL_SECONDS = exports.OXY_APP_ASSERTION_HEADER = exports.OXY_APP_ASSERTION_AUDIENCE = exports.APP_ASSERTION_PLATFORMS = exports.APP_ASSERTION_ERROR_CODES = exports.APP_ASSERTION_CHALLENGE_PURPOSES = void 0;
|
|
4
4
|
exports.isExactHttpsOrigin = isExactHttpsOrigin;
|
|
5
5
|
const stringChecks_1 = require("./stringChecks");
|
|
6
6
|
/**
|
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "OXY_APP_ASSERTION_AUDIENCE", { enumerable: true,
|
|
|
36
36
|
Object.defineProperty(exports, "OXY_APP_ASSERTION_HEADER", { enumerable: true, get: function () { return appAssertions_1.OXY_APP_ASSERTION_HEADER; } });
|
|
37
37
|
Object.defineProperty(exports, "OXY_APP_ASSERTION_TTL_SECONDS", { enumerable: true, get: function () { return appAssertions_1.OXY_APP_ASSERTION_TTL_SECONDS; } });
|
|
38
38
|
Object.defineProperty(exports, "OXY_APP_ASSERTION_TYPE", { enumerable: true, get: function () { return appAssertions_1.OXY_APP_ASSERTION_TYPE; } });
|
|
39
|
+
const platformSession_1 = require("./client/platformSession");
|
|
39
40
|
const applicationIdSchema = zod_1.z.string().trim().check((0, stringChecks_1.utf16MinLength)(1)).check((0, stringChecks_1.utf16MaxLength)(255));
|
|
40
41
|
const base64Url32Schema = zod_1.z.string().regex(/^[A-Za-z0-9_-]{43}$/);
|
|
41
42
|
const base64Schema = (max) => zod_1.z
|
|
@@ -44,6 +45,8 @@ const base64Schema = (max) => zod_1.z
|
|
|
44
45
|
.check((0, stringChecks_1.utf16MaxLength)(max))
|
|
45
46
|
.regex(/^[A-Za-z0-9+/]+={0,2}$/);
|
|
46
47
|
exports.appAssertionPlatformSchema = zod_1.z.enum(appAssertions_1.APP_ASSERTION_PLATFORMS);
|
|
48
|
+
/** A platform that holds the Oxy session for the applications it runs (ADR 0058). */
|
|
49
|
+
exports.platformHostSchema = zod_1.z.enum(platformSession_1.PLATFORM_HOSTS);
|
|
47
50
|
exports.appAssertionErrorCodeSchema = zod_1.z.enum(appAssertions_1.APP_ASSERTION_ERROR_CODES);
|
|
48
51
|
// ---------------------------------------------------------------------------
|
|
49
52
|
// Registry
|
|
@@ -79,6 +82,11 @@ exports.appleBundleIdSchema = zod_1.z
|
|
|
79
82
|
.string()
|
|
80
83
|
.check((0, stringChecks_1.utf16MaxLength)(255))
|
|
81
84
|
.regex(/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/, 'Must be an Apple bundle id');
|
|
85
|
+
/** An OxyOS desktop entry id (`so.oxy.dropsea`), the id OxyOS launches the application by. */
|
|
86
|
+
exports.oxyosDesktopEntryIdSchema = zod_1.z
|
|
87
|
+
.string()
|
|
88
|
+
.check((0, stringChecks_1.utf16MaxLength)(255))
|
|
89
|
+
.regex(platformSession_1.OXYOS_DESKTOP_ENTRY_ID_PATTERN, 'Must be an OxyOS desktop entry id');
|
|
82
90
|
const unique = (values) => new Set(values).size === values.length;
|
|
83
91
|
exports.applicationAndroidRecognitionSchema = zod_1.z
|
|
84
92
|
.object({
|
|
@@ -93,9 +101,22 @@ exports.applicationAndroidRecognitionSchema = zod_1.z
|
|
|
93
101
|
exports.applicationIosRecognitionSchema = zod_1.z
|
|
94
102
|
.object({ teamId: exports.appleTeamIdSchema, bundleId: exports.appleBundleIdSchema })
|
|
95
103
|
.strict();
|
|
104
|
+
const oxyosDesktopEntryIdsSchema = zod_1.z
|
|
105
|
+
.array(exports.oxyosDesktopEntryIdSchema)
|
|
106
|
+
.max(20)
|
|
107
|
+
.refine(unique, 'Desktop entry ids must be unique');
|
|
96
108
|
/**
|
|
97
109
|
* What Oxy staff write for an application: the whole declaration, replaced at
|
|
98
110
|
* once. `null` and `[]` declare nothing for that platform.
|
|
111
|
+
*
|
|
112
|
+
* ADR 0058 adds two fields a writer may omit, and an omitted one is left as
|
|
113
|
+
* the registry holds it (a writer that predates them cannot erase them):
|
|
114
|
+
*
|
|
115
|
+
* - `platformHost`: this application IS a platform that holds the Oxy session
|
|
116
|
+
* (OxyOS, Astro). Its public client id is the one a platform's own sign-in
|
|
117
|
+
* names (`platformClient`), and only an Oxy application may declare it.
|
|
118
|
+
* - `oxyosDesktopEntryIds`: the OxyOS desktop entry ids that launch this
|
|
119
|
+
* application, each naming one application only, as a web origin does.
|
|
99
120
|
*/
|
|
100
121
|
exports.applicationRecognitionWriteSchema = zod_1.z
|
|
101
122
|
.object({
|
|
@@ -105,12 +126,16 @@ exports.applicationRecognitionWriteSchema = zod_1.z
|
|
|
105
126
|
.refine(unique, 'Origins must be unique'),
|
|
106
127
|
android: exports.applicationAndroidRecognitionSchema.nullable(),
|
|
107
128
|
ios: exports.applicationIosRecognitionSchema.nullable(),
|
|
129
|
+
platformHost: exports.platformHostSchema.nullable().optional(),
|
|
130
|
+
oxyosDesktopEntryIds: oxyosDesktopEntryIdsSchema.optional(),
|
|
108
131
|
})
|
|
109
132
|
.strict();
|
|
110
133
|
/** An application's recognition as the registry holds it; `updatedAt` is `null` when none was written. */
|
|
111
134
|
exports.applicationRecognitionSchema = exports.applicationRecognitionWriteSchema
|
|
112
135
|
.extend({
|
|
113
136
|
applicationId: applicationIdSchema,
|
|
137
|
+
platformHost: exports.platformHostSchema.nullable(),
|
|
138
|
+
oxyosDesktopEntryIds: oxyosDesktopEntryIdsSchema,
|
|
114
139
|
updatedAt: zod_1.z.string().check((0, stringChecks_1.isoDateTime)()).nullable(),
|
|
115
140
|
})
|
|
116
141
|
.strict();
|
|
@@ -161,10 +186,14 @@ exports.appAttestKeyResponseSchema = zod_1.z.object({ keyId: exports.appAttestKe
|
|
|
161
186
|
* `POST /apps/assertions`. The body names the application and the platform;
|
|
162
187
|
* the proof is the platform's: none on the web (the browser's `Origin` is), a
|
|
163
188
|
* Play Integrity token on Android, an App Attest assertion on iOS, each over a
|
|
164
|
-
* challenge minted for `assertion`.
|
|
189
|
+
* challenge minted for `assertion`. On `oxyos` and `astro` the bearer is the
|
|
190
|
+
* proof: an application token that platform minted for this application
|
|
191
|
+
* (ADR 0058).
|
|
165
192
|
*/
|
|
166
193
|
exports.appAssertionRequestSchema = zod_1.z.discriminatedUnion('platform', [
|
|
167
194
|
zod_1.z.object({ applicationId: applicationIdSchema, platform: zod_1.z.literal('web') }).strict(),
|
|
195
|
+
zod_1.z.object({ applicationId: applicationIdSchema, platform: zod_1.z.literal('oxyos') }).strict(),
|
|
196
|
+
zod_1.z.object({ applicationId: applicationIdSchema, platform: zod_1.z.literal('astro') }).strict(),
|
|
168
197
|
zod_1.z
|
|
169
198
|
.object({
|
|
170
199
|
applicationId: applicationIdSchema,
|
|
@@ -13,8 +13,12 @@
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.appAssertionResponseCheck = exports.appAttestKeyResponseCheck = exports.appAssertionChallengeResponseCheck = exports.APP_ASSERTION_ERROR_CODES = exports.OXY_APP_ASSERTION_TTL_SECONDS = exports.OXY_APP_ASSERTION_HEADER = exports.OXY_APP_ASSERTION_AUDIENCE = exports.OXY_APP_ASSERTION_TYPE = exports.APP_ASSERTION_CHALLENGE_PURPOSES = exports.APP_ASSERTION_PLATFORMS = void 0;
|
|
15
15
|
const check_1 = require("./check");
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* How an app proves itself: the browser's origin, Play Integrity, App Attest,
|
|
18
|
+
* or (`oxyos`, `astro`) an application token the platform holding the session
|
|
19
|
+
* minted for it (ADR 0058), whose bearer is the proof.
|
|
20
|
+
*/
|
|
21
|
+
exports.APP_ASSERTION_PLATFORMS = ['web', 'android', 'ios', 'oxyos', 'astro'];
|
|
18
22
|
/**
|
|
19
23
|
* What a device challenge is spent on: an assertion, or (iOS only) registering
|
|
20
24
|
* an App Attest key. A challenge minted for one is refused for the other.
|
|
@@ -45,6 +49,9 @@ exports.OXY_APP_ASSERTION_TTL_SECONDS = 300;
|
|
|
45
49
|
* - `attestation_invalid`: the App Attest attestation does not verify.
|
|
46
50
|
* - `assertion_invalid`: the App Attest assertion does not verify, or its counter did not advance.
|
|
47
51
|
* - `signing_unavailable`: Oxy cannot sign (503).
|
|
52
|
+
* - `app_token_mismatch`: an `oxyos` or `astro` assertion needs an application token that
|
|
53
|
+
* platform minted for this application; an application token gets an assertion for its own
|
|
54
|
+
* application and platform only.
|
|
48
55
|
*/
|
|
49
56
|
exports.APP_ASSERTION_ERROR_CODES = [
|
|
50
57
|
'application_unavailable',
|
|
@@ -60,6 +67,7 @@ exports.APP_ASSERTION_ERROR_CODES = [
|
|
|
60
67
|
'attestation_invalid',
|
|
61
68
|
'assertion_invalid',
|
|
62
69
|
'signing_unavailable',
|
|
70
|
+
'app_token_mismatch',
|
|
63
71
|
];
|
|
64
72
|
/** 32 random bytes, base64url: a challenge, or the SHA-256 it is bound into. */
|
|
65
73
|
const BASE64URL_32 = /^[A-Za-z0-9_-]{43}$/;
|
package/dist/cjs/client/index.js
CHANGED
|
@@ -34,7 +34,7 @@ exports.ORGANIZATION_KEY_PROOF_ACTION_VALUES = exports.ORGANIZATION_KEY_PROOF_AC
|
|
|
34
34
|
exports.ORGANIZATION_NAME_MAX_LENGTH = exports.ORGANIZATION_ERROR_CODES = exports.ORGANIZATION_CLAIM_STATUSES = exports.ORGANIZATION_CLAIM_DECISIONS = exports.ORGANIZATION_ALIAS_KINDS = exports.canonicalJson = exports.buildIdentityProofMessage = exports.IDENTITY_PROOF_VERSION = exports.IDENTITY_PROOF_DOMAIN = exports.IDENTITY_PROOF_CHALLENGE_TTL_MS = exports.IDENTITY_PROOF_AUDIENCE = exports.IDENTITY_PROOF_ACTION_VALUES = exports.IDENTITY_PROOF_ACTIONS = exports.IDENTITY_ERROR_CODES = exports.parseIdentityLinkQrPayload = exports.identityLinkStateCheck = exports.identityLinkCreateResponseCheck = exports.buildIdentityLinkQrPayload = exports.IDENTITY_LINK_STATUSES = exports.IDENTITY_LINK_QR_PREFIX = exports.identityKeyHistoryCheck = exports.sessionAccountsChangedEventCheck = exports.deviceTokenMintResponseCheck = exports.deviceSessionSyncCheck = exports.deviceSessionStateCheck = exports.deviceRegisterResponseCheck = exports.deviceJoinResponseCheck = exports.deviceJoinCodeResponseCheck = exports.holderContextEvidenceV1ResponseCheck = exports.holderContextEvidenceV1RequestCheck = exports.deviceContextTokenV1ResponseCheck = exports.deviceContextTokenV1RequestCheck = exports.deviceBackgroundCredentialResponseCheck = exports.activeTokenCheck = exports.SESSION_ACCOUNTS_CHANGED_EVENT = exports.deviceDirectorySyncCheck = exports.deviceDirectoryCheck = exports.deviceActivateResponseCheck = exports.normalizeDomainName = exports.DOMAIN_NAME_MAX_LENGTH = exports.signedRecordEnvelopeCheck = exports.externalIdentityReferenceCheck = exports.loginResultCheck = exports.isLoopbackOrigin = exports.organizationKeyProofClaims = exports.organizationKeyPayload = exports.organizationKeyChallengeRequestCheck = exports.organizationKeyChallengeCheck = exports.organizationKeyApplyRequestCheck = exports.organizationIdentityKeyStateCheck = void 0;
|
|
35
35
|
exports.supervisionContactInputCheck = exports.supervisionAcceptInputCheck = exports.safetyPeopleResponseCheck = exports.safetyPeopleInputCheck = exports.safetyOrganizationsResponseCheck = exports.safetyOrganizationsInputCheck = exports.purchaseReviewInputCheck = exports.purchaseApprovalListCheck = exports.purchaseApprovalCheck = exports.profileAccessInputCheck = exports.profileAccessDecisionCheck = exports.SUPERVISION_STATUSES = exports.SUPERVISION_INVITATION_STATUSES = exports.SUPERVISION_CONSENT_VERSION = exports.SUPERVISION_CHANGED_EVENT = exports.SUPERVISED_ACTIONS = exports.SAFETY_POLICY_VERSION = exports.PURCHASE_APPROVAL_STATUSES = exports.isFullReputationBalance = exports.recommendationRequestCheck = exports.subscriptionCreditGrantsResponseCheck = exports.subjectProductAccessQueryCheck = exports.subjectProductAccessCheck = exports.productSubscriptionsResponseCheck = exports.productSubscriptionPortalResponseCheck = exports.productSubscriptionPortalRequestCheck = exports.productSubscriptionCancellationResultCheck = exports.productPlanCheckoutRequestCheck = exports.productPlanCatalogueCheck = exports.personalPlanCheckoutResultCheck = exports.personalPlanCheckoutRequestCheck = exports.personalPlanCatalogueCheck = exports.cancelProductSubscriptionCheck = exports.updateOrganizationCheck = exports.organizationNameCheck = exports.organizationListCheck = exports.organizationImportBatchResultCheck = exports.organizationExternalResolutionCheck = exports.organizationExternalCheck = exports.organizationCurationResultCheck = exports.organizationClaimReviewCheck = exports.organizationClaimListCheck = exports.organizationClaimInputCheck = exports.organizationClaimDetailCheck = exports.organizationClaimCheck = exports.organizationCheck = exports.organizationBatchCheck = exports.createOrganizationCheck = exports.ORGANIZATION_TYPES = exports.ORGANIZATION_STATUSES = void 0;
|
|
36
36
|
exports.usernameCheckForAccountKind = exports.usernameCheck = exports.stripDisallowedUsernameCharacters = exports.botUsernameCheck = exports.applyBotUsernameSuffix = exports.USERNAME_PATTERN_SOURCE = exports.USERNAME_MIN_LENGTH = exports.USERNAME_MAX_LENGTH = exports.USERNAME_INVALID_MESSAGE = exports.RESERVED_USERNAME_MESSAGE = exports.RESERVED_USERNAMES = exports.NUMERIC_USERNAME_MESSAGE = exports.BOT_USERNAME_SUFFIX = exports.BOT_USERNAME_INVALID_MESSAGE = exports.totpEnrollResponseCheck = exports.totpBackupCodesResponseCheck = exports.signInMethodsCheck = exports.secondFactorRequiredCheck = exports.reauthProofCheck = exports.normalizeEmailSignInCode = exports.isSecondFactorRequired = exports.isEmailSignInChooseAccount = exports.emailSignInStartResponseCheck = exports.emailSignInPendingCheck = exports.emailSignInLinkResponseCheck = exports.emailSignInChooseAccountCheck = exports.TOTP_PERIOD_SECONDS = exports.TOTP_DIGITS = exports.TOTP_BACKUP_CODE_COUNT = exports.SIGN_IN_ERROR_CODES = exports.SIGNIN_SECOND_FACTOR_TTL_MS = exports.SIGNIN_SECOND_FACTOR_MAX_ATTEMPTS = exports.SIGN_IN_IDENTIFIER_MAX_LENGTH = exports.SECOND_FACTOR_CODE_MAX_LENGTH = exports.REAUTH_ACTIONS = exports.PASSWORD_MIN_LENGTH = exports.PASSWORD_MAX_LENGTH = exports.EMAIL_SIGNIN_LONG_CODE_LENGTH = exports.EMAIL_SIGNIN_LONG_CODE_ALPHABET = exports.EMAIL_SIGNIN_LINK_TTL_MS = exports.EMAIL_SIGNIN_CHOICE_TTL_MS = exports.EMAIL_ACCOUNTS_MAX = exports.CONSOLE_USE_CASES = exports.CONSOLE_TERMS_VERSION = exports.publicApplicationCheck = exports.supervisionStateCheck = exports.supervisionReviewInputCheck = exports.supervisionInviteInputCheck = exports.supervisionInvitationCheck = exports.supervisionContactsResponseCheck = void 0;
|
|
37
|
-
exports.isLanguageTag = exports.hasCampaignControlCharacters = exports.CAMPAIGN_CLICK_ID_MAX_LENGTH = exports.CAMPAIGN_LABEL_MAX_LENGTH = exports.FREE_USER_PROFILE_COLOR_PRESETS = exports.USER_PROFILE_COLOR_PRESETS = exports.USER_PROFILE_COLORS = exports.appAttestKeyResponseCheck = exports.appAssertionResponseCheck = exports.appAssertionChallengeResponseCheck = exports.OXY_APP_ASSERTION_TYPE = exports.OXY_APP_ASSERTION_TTL_SECONDS = exports.OXY_APP_ASSERTION_HEADER = exports.OXY_APP_ASSERTION_AUDIENCE = exports.APP_ASSERTION_PLATFORMS = exports.APP_ASSERTION_ERROR_CODES = exports.APP_ASSERTION_CHALLENGE_PURPOSES = exports.isRightsClaim = exports.isErasureRequest = exports.OPEN_CONTENT_CLAIM_STATES = exports.ERASURE_REQUEST_DEADLINE_DAYS = exports.COUNTER_NOTICE_STATEMENTS = exports.COUNTER_NOTICE_STATEMENT_VERSION = exports.CONTENT_CLAIM_STATES = exports.CONTENT_CLAIM_REFERENCE_PATTERN = exports.CONTENT_CLAIM_LIMITS = exports.CONTENT_CLAIM_KINDS = exports.CONTENT_CLAIM_ERROR_CODES = exports.CONTENT_CLAIM_COUNTER_NOTICE_LIMITS = exports.CLOSED_CONTENT_CLAIM_STATES = exports.CLAIMANT_RELATIONSHIPS = exports.PRONOUNS = exports.PROFILE_LINK_TITLE_MAX = exports.PROFILE_LINKS_MAX = exports.userNameCheck = void 0;
|
|
37
|
+
exports.isLanguageTag = exports.hasCampaignControlCharacters = exports.CAMPAIGN_CLICK_ID_MAX_LENGTH = exports.CAMPAIGN_LABEL_MAX_LENGTH = exports.FREE_USER_PROFILE_COLOR_PRESETS = exports.USER_PROFILE_COLOR_PRESETS = exports.USER_PROFILE_COLORS = exports.deviceAppTokenResponseCheck = exports.PLATFORM_HOSTS = exports.OXYOS_DESKTOP_ENTRY_ID_PATTERN = exports.DEVICE_APP_TOKEN_TTL_SECONDS = exports.DEVICE_APP_TOKEN_ERROR_CODES = exports.APP_TOKEN_DEVICE_ACCESS_DENIED = exports.appAttestKeyResponseCheck = exports.appAssertionResponseCheck = exports.appAssertionChallengeResponseCheck = exports.OXY_APP_ASSERTION_TYPE = exports.OXY_APP_ASSERTION_TTL_SECONDS = exports.OXY_APP_ASSERTION_HEADER = exports.OXY_APP_ASSERTION_AUDIENCE = exports.APP_ASSERTION_PLATFORMS = exports.APP_ASSERTION_ERROR_CODES = exports.APP_ASSERTION_CHALLENGE_PURPOSES = exports.isRightsClaim = exports.isErasureRequest = exports.OPEN_CONTENT_CLAIM_STATES = exports.ERASURE_REQUEST_DEADLINE_DAYS = exports.COUNTER_NOTICE_STATEMENTS = exports.COUNTER_NOTICE_STATEMENT_VERSION = exports.CONTENT_CLAIM_STATES = exports.CONTENT_CLAIM_REFERENCE_PATTERN = exports.CONTENT_CLAIM_LIMITS = exports.CONTENT_CLAIM_KINDS = exports.CONTENT_CLAIM_ERROR_CODES = exports.CONTENT_CLAIM_COUNTER_NOTICE_LIMITS = exports.CLOSED_CONTENT_CLAIM_STATES = exports.CLAIMANT_RELATIONSHIPS = exports.PRONOUNS = exports.PROFILE_LINK_TITLE_MAX = exports.PROFILE_LINKS_MAX = exports.userNameCheck = void 0;
|
|
38
38
|
var check_1 = require("./check");
|
|
39
39
|
Object.defineProperty(exports, "ContractCheckError", { enumerable: true, get: function () { return check_1.ContractCheckError; } });
|
|
40
40
|
Object.defineProperty(exports, "checkContract", { enumerable: true, get: function () { return check_1.checkContract; } });
|
|
@@ -292,6 +292,13 @@ Object.defineProperty(exports, "OXY_APP_ASSERTION_TYPE", { enumerable: true, get
|
|
|
292
292
|
Object.defineProperty(exports, "appAssertionChallengeResponseCheck", { enumerable: true, get: function () { return appAssertions_1.appAssertionChallengeResponseCheck; } });
|
|
293
293
|
Object.defineProperty(exports, "appAssertionResponseCheck", { enumerable: true, get: function () { return appAssertions_1.appAssertionResponseCheck; } });
|
|
294
294
|
Object.defineProperty(exports, "appAttestKeyResponseCheck", { enumerable: true, get: function () { return appAssertions_1.appAttestKeyResponseCheck; } });
|
|
295
|
+
var platformSession_1 = require("./platformSession");
|
|
296
|
+
Object.defineProperty(exports, "APP_TOKEN_DEVICE_ACCESS_DENIED", { enumerable: true, get: function () { return platformSession_1.APP_TOKEN_DEVICE_ACCESS_DENIED; } });
|
|
297
|
+
Object.defineProperty(exports, "DEVICE_APP_TOKEN_ERROR_CODES", { enumerable: true, get: function () { return platformSession_1.DEVICE_APP_TOKEN_ERROR_CODES; } });
|
|
298
|
+
Object.defineProperty(exports, "DEVICE_APP_TOKEN_TTL_SECONDS", { enumerable: true, get: function () { return platformSession_1.DEVICE_APP_TOKEN_TTL_SECONDS; } });
|
|
299
|
+
Object.defineProperty(exports, "OXYOS_DESKTOP_ENTRY_ID_PATTERN", { enumerable: true, get: function () { return platformSession_1.OXYOS_DESKTOP_ENTRY_ID_PATTERN; } });
|
|
300
|
+
Object.defineProperty(exports, "PLATFORM_HOSTS", { enumerable: true, get: function () { return platformSession_1.PLATFORM_HOSTS; } });
|
|
301
|
+
Object.defineProperty(exports, "deviceAppTokenResponseCheck", { enumerable: true, get: function () { return platformSession_1.deviceAppTokenResponseCheck; } });
|
|
295
302
|
var profileColors_generated_1 = require("../profileColors.generated");
|
|
296
303
|
Object.defineProperty(exports, "USER_PROFILE_COLORS", { enumerable: true, get: function () { return profileColors_generated_1.USER_PROFILE_COLORS; } });
|
|
297
304
|
Object.defineProperty(exports, "USER_PROFILE_COLOR_PRESETS", { enumerable: true, get: function () { return profileColors_generated_1.USER_PROFILE_COLOR_PRESETS; } });
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A platform that holds the Oxy session (ADR 0058), without Zod. Schemas:
|
|
4
|
+
* `../platformSession.ts`.
|
|
5
|
+
*
|
|
6
|
+
* OxyOS and Astro hold the person's Oxy session themselves, on a PLATFORM
|
|
7
|
+
* CREDENTIAL, and ask Oxy for a short token named for each application they
|
|
8
|
+
* run (`POST /session/device/app-token`). Applications hold no credential.
|
|
9
|
+
*
|
|
10
|
+
* Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.deviceAppTokenResponseCheck = exports.APP_TOKEN_DEVICE_ACCESS_DENIED = exports.DEVICE_APP_TOKEN_ERROR_CODES = exports.DEVICE_APP_TOKEN_TTL_SECONDS = exports.OXYOS_DESKTOP_ENTRY_ID_PATTERN = exports.PLATFORM_HOSTS = void 0;
|
|
14
|
+
const check_1 = require("./check");
|
|
15
|
+
/** The platforms that hold the Oxy session for the applications they run. */
|
|
16
|
+
exports.PLATFORM_HOSTS = ['oxyos', 'astro'];
|
|
17
|
+
/**
|
|
18
|
+
* An OxyOS desktop entry id (`so.oxy.dropsea`): the reverse-DNS id OxyOS names
|
|
19
|
+
* an application by in its registry and launch records. Lowercase, at least two
|
|
20
|
+
* segments, unique across applications like a web origin.
|
|
21
|
+
*/
|
|
22
|
+
exports.OXYOS_DESKTOP_ENTRY_ID_PATTERN = /^[a-z0-9]+(\.[a-z0-9-]+)+$/;
|
|
23
|
+
/** An application token lives exactly this long (ADR 0058 2.3). */
|
|
24
|
+
exports.DEVICE_APP_TOKEN_TTL_SECONDS = 300;
|
|
25
|
+
/**
|
|
26
|
+
* Why `POST /session/device/app-token` refused. The API answers `{ error: <code> }`.
|
|
27
|
+
*
|
|
28
|
+
* - `invalid_request` (400): the body is not the contract's.
|
|
29
|
+
* - `browser_not_allowed` (403): the request carries a web `Origin` (or
|
|
30
|
+
* `Sec-Fetch-Site`); only a platform's own native service mints.
|
|
31
|
+
* - `invalid_device_secret` (401): the secret proves no PLATFORM credential of
|
|
32
|
+
* that device. A wrong secret counts toward the device-secret lockout.
|
|
33
|
+
* - `application_not_recognised` (403): the credential is another platform's,
|
|
34
|
+
* or the attestation names no active Oxy application recognised for this
|
|
35
|
+
* platform (an unknown desktop entry id, an origin that is not the
|
|
36
|
+
* application's, auth.oxy.so's application, a third-party application, a
|
|
37
|
+
* `clientId` of another application).
|
|
38
|
+
* - `no_active_session` / `account_not_on_device` (401): as
|
|
39
|
+
* `POST /session/device/token`: nothing live to mint for, or the pinned
|
|
40
|
+
* account is not live on the device.
|
|
41
|
+
*/
|
|
42
|
+
exports.DEVICE_APP_TOKEN_ERROR_CODES = [
|
|
43
|
+
'invalid_request',
|
|
44
|
+
'browser_not_allowed',
|
|
45
|
+
'invalid_device_secret',
|
|
46
|
+
'application_not_recognised',
|
|
47
|
+
'no_active_session',
|
|
48
|
+
'account_not_on_device',
|
|
49
|
+
];
|
|
50
|
+
/**
|
|
51
|
+
* Every bearer-authenticated `/session/device/*` route answers an application
|
|
52
|
+
* token (one carrying `host`) with `403 { error: APP_TOKEN_DEVICE_ACCESS_DENIED }`:
|
|
53
|
+
* the device is the platform's, never an application's.
|
|
54
|
+
*/
|
|
55
|
+
exports.APP_TOKEN_DEVICE_ACCESS_DENIED = 'app_token_device_access_denied';
|
|
56
|
+
exports.deviceAppTokenResponseCheck = (0, check_1.exact)()((0, check_1.object)({
|
|
57
|
+
accessToken: (0, check_1.string)((0, check_1.minLength)(1)),
|
|
58
|
+
expiresAt: (0, check_1.string)(check_1.datetime),
|
|
59
|
+
applicationId: (0, check_1.string)((0, check_1.minLength)(1)),
|
|
60
|
+
accountId: (0, check_1.string)((0, check_1.minLength)(1)),
|
|
61
|
+
}));
|
package/dist/cjs/index.js
CHANGED
|
@@ -912,6 +912,7 @@ __exportStar(require("./serviceToken"), exports);
|
|
|
912
912
|
__exportStar(require("./applicationRoles"), exports);
|
|
913
913
|
__exportStar(require("./contentClaims"), exports);
|
|
914
914
|
__exportStar(require("./appAssertions"), exports);
|
|
915
|
+
__exportStar(require("./platformSession"), exports);
|
|
915
916
|
__exportStar(require("./products/one"), exports);
|
|
916
917
|
var profileColors_generated_1 = require("./profileColors.generated");
|
|
917
918
|
Object.defineProperty(exports, "USER_PROFILE_COLORS", { enumerable: true, get: function () { return profileColors_generated_1.USER_PROFILE_COLORS; } });
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A platform that holds the Oxy session (ADR 0058).
|
|
4
|
+
*
|
|
5
|
+
* OxyOS (`oxyos-accountd`) and Astro hold the person's Oxy session on a
|
|
6
|
+
* PLATFORM CREDENTIAL: a device holder credential issued to the platform's own
|
|
7
|
+
* sign-in, the one that names it with {@link platformClientSchema}
|
|
8
|
+
* (`POST /auth/signin/password`, completed by `POST /auth/signin/second-factor`).
|
|
9
|
+
* Applications they run hold nothing; the platform asks
|
|
10
|
+
* `POST /session/device/app-token` for a five-minute token named for each one
|
|
11
|
+
* (`azp`, and the `host` claim naming the platform and its credential).
|
|
12
|
+
*
|
|
13
|
+
* The Zod-free half (vocabularies, the response check) is
|
|
14
|
+
* `./client/platformSession.ts`.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.hostTokenValidationSchema = exports.hostTokenClaimSchema = exports.deviceAppTokenResponseSchema = exports.deviceAppTokenRequestSchema = exports.deviceAppTokenAttestationSchema = exports.platformClientSchema = exports.PLATFORM_HOSTS = exports.OXYOS_DESKTOP_ENTRY_ID_PATTERN = exports.DEVICE_APP_TOKEN_TTL_SECONDS = exports.DEVICE_APP_TOKEN_ERROR_CODES = exports.APP_TOKEN_DEVICE_ACCESS_DENIED = void 0;
|
|
18
|
+
const zod_1 = require("zod");
|
|
19
|
+
const appAssertions_1 = require("./appAssertions");
|
|
20
|
+
const platformSession_1 = require("./client/platformSession");
|
|
21
|
+
Object.defineProperty(exports, "APP_TOKEN_DEVICE_ACCESS_DENIED", { enumerable: true, get: function () { return platformSession_1.APP_TOKEN_DEVICE_ACCESS_DENIED; } });
|
|
22
|
+
Object.defineProperty(exports, "DEVICE_APP_TOKEN_ERROR_CODES", { enumerable: true, get: function () { return platformSession_1.DEVICE_APP_TOKEN_ERROR_CODES; } });
|
|
23
|
+
Object.defineProperty(exports, "DEVICE_APP_TOKEN_TTL_SECONDS", { enumerable: true, get: function () { return platformSession_1.DEVICE_APP_TOKEN_TTL_SECONDS; } });
|
|
24
|
+
Object.defineProperty(exports, "OXYOS_DESKTOP_ENTRY_ID_PATTERN", { enumerable: true, get: function () { return platformSession_1.OXYOS_DESKTOP_ENTRY_ID_PATTERN; } });
|
|
25
|
+
Object.defineProperty(exports, "PLATFORM_HOSTS", { enumerable: true, get: function () { return platformSession_1.PLATFORM_HOSTS; } });
|
|
26
|
+
const stringChecks_1 = require("./stringChecks");
|
|
27
|
+
const publicClientIdSchema = zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)).check((0, stringChecks_1.utf16MaxLength)(256));
|
|
28
|
+
/**
|
|
29
|
+
* Names the platform on its own password sign-in, and on the second factor
|
|
30
|
+
* completing it. Honoured only when the request has NO web `Origin` and
|
|
31
|
+
* `clientId` is a live public client id of an active Oxy application whose
|
|
32
|
+
* registry entry declares `platformHost` equal to `platform`; anything else is
|
|
33
|
+
* refused with the ordinary invalid-request answer before any account lookup or
|
|
34
|
+
* password work. When honoured, the device credential the sign-in returns is a
|
|
35
|
+
* platform credential, and a credential the sign-in's `device` proof presented
|
|
36
|
+
* is retired.
|
|
37
|
+
*/
|
|
38
|
+
exports.platformClientSchema = zod_1.z.strictObject({
|
|
39
|
+
platform: appAssertions_1.platformHostSchema,
|
|
40
|
+
clientId: publicClientIdSchema,
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Which application the token is for, as the platform vouches for it:
|
|
44
|
+
*
|
|
45
|
+
* - `{ platform: 'oxyos', desktopEntryId }`: an application OxyOS launched,
|
|
46
|
+
* by the desktop entry id its registry entry declares;
|
|
47
|
+
* - `{ platform, self: true }`: the platform's own application (OxyOS's
|
|
48
|
+
* Settings and shell, Astro's chrome);
|
|
49
|
+
* - `{ platform: 'astro', origin, clientId }`: an Oxy web application Astro
|
|
50
|
+
* shows, by the exact origin it committed and the application's client id.
|
|
51
|
+
*/
|
|
52
|
+
exports.deviceAppTokenAttestationSchema = zod_1.z.union([
|
|
53
|
+
zod_1.z.strictObject({ platform: zod_1.z.literal('oxyos'), desktopEntryId: appAssertions_1.oxyosDesktopEntryIdSchema }),
|
|
54
|
+
zod_1.z.strictObject({ platform: appAssertions_1.platformHostSchema, self: zod_1.z.literal(true) }),
|
|
55
|
+
zod_1.z.strictObject({
|
|
56
|
+
platform: zod_1.z.literal('astro'),
|
|
57
|
+
origin: appAssertions_1.applicationWebOriginSchema,
|
|
58
|
+
clientId: publicClientIdSchema,
|
|
59
|
+
}),
|
|
60
|
+
]);
|
|
61
|
+
/**
|
|
62
|
+
* `POST /session/device/app-token`: the platform credential (no bearer;
|
|
63
|
+
* possession is the proof, as at `POST /session/device/token`), the
|
|
64
|
+
* attestation, and optionally `accountId` (pins the account, as that mint's
|
|
65
|
+
* does) and `clientId` (when given, a public client id of the SAME application
|
|
66
|
+
* the attestation names).
|
|
67
|
+
*/
|
|
68
|
+
exports.deviceAppTokenRequestSchema = zod_1.z.strictObject({
|
|
69
|
+
deviceId: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)).check((0, stringChecks_1.utf16MaxLength)(128)),
|
|
70
|
+
deviceSecret: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)).check((0, stringChecks_1.utf16MaxLength)(256)),
|
|
71
|
+
accountId: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)).check((0, stringChecks_1.utf16MaxLength)(128)).optional(),
|
|
72
|
+
clientId: publicClientIdSchema.optional(),
|
|
73
|
+
attestation: exports.deviceAppTokenAttestationSchema,
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* The application's token: a fresh access token of the device's shared session
|
|
77
|
+
* for `accountId`, named for `applicationId` (`azp`, its public client id) and
|
|
78
|
+
* carrying `host`. `expiresAt` is the token's own `exp`
|
|
79
|
+
* ({@link DEVICE_APP_TOKEN_TTL_SECONDS} after it was minted).
|
|
80
|
+
*/
|
|
81
|
+
exports.deviceAppTokenResponseSchema = zod_1.z.object({
|
|
82
|
+
accessToken: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)),
|
|
83
|
+
expiresAt: zod_1.z.string().check((0, stringChecks_1.isoDateTime)()),
|
|
84
|
+
applicationId: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)),
|
|
85
|
+
accountId: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)),
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* The `host` claim of an application token: the platform that vouched for the
|
|
89
|
+
* application and the id of its platform credential. Oxy re-checks both on
|
|
90
|
+
* every request (the credential is live and the platform's, `azp` is a live
|
|
91
|
+
* public client of an active Oxy application).
|
|
92
|
+
*/
|
|
93
|
+
exports.hostTokenClaimSchema = zod_1.z.strictObject({
|
|
94
|
+
platform: appAssertions_1.platformHostSchema,
|
|
95
|
+
credential: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)).check((0, stringChecks_1.utf16MaxLength)(128)),
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* What `GET /session/validate-header/:sessionId` adds for an application token:
|
|
99
|
+
* the application it is named for and the platform that vouched for it.
|
|
100
|
+
*/
|
|
101
|
+
exports.hostTokenValidationSchema = zod_1.z.object({
|
|
102
|
+
applicationId: zod_1.z.string().check((0, stringChecks_1.utf16MinLength)(1)),
|
|
103
|
+
platform: appAssertions_1.platformHostSchema,
|
|
104
|
+
});
|
package/dist/cjs/signIn.js
CHANGED
|
@@ -39,6 +39,7 @@ const stringChecks_1 = require("./stringChecks");
|
|
|
39
39
|
const zod_1 = require("zod");
|
|
40
40
|
const accountEmail_1 = require("./accountEmail");
|
|
41
41
|
const deviceSession_1 = require("./deviceSession");
|
|
42
|
+
const platformSession_1 = require("./platformSession");
|
|
42
43
|
// The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
|
|
43
44
|
// it is re-exported here so the root entry is unchanged.
|
|
44
45
|
const signIn_1 = require("./client/signIn");
|
|
@@ -170,20 +171,29 @@ exports.emailSignInLinkRequestSchema = zod_1.z
|
|
|
170
171
|
exports.emailSignInLinkResponseSchema = zod_1.z.object({
|
|
171
172
|
approved: zod_1.z.literal(true),
|
|
172
173
|
});
|
|
173
|
-
/**
|
|
174
|
+
/**
|
|
175
|
+
* `POST /auth/signin/password`. `platformClient` is a platform's own sign-in
|
|
176
|
+
* (ADR 0058): see `platformClientSchema`.
|
|
177
|
+
*/
|
|
174
178
|
exports.passwordSignInRequestSchema = zod_1.z
|
|
175
179
|
.object({
|
|
176
180
|
identifier: exports.signInIdentifierSchema,
|
|
177
181
|
password: exports.passwordInputSchema,
|
|
178
182
|
...sessionEnvelope,
|
|
183
|
+
platformClient: platformSession_1.platformClientSchema.optional(),
|
|
179
184
|
})
|
|
180
185
|
.strict();
|
|
181
|
-
/**
|
|
186
|
+
/**
|
|
187
|
+
* `POST /auth/signin/second-factor`. A challenge a platform's sign-in received
|
|
188
|
+
* is completed naming the SAME `platformClient`, and one that named none
|
|
189
|
+
* naming none.
|
|
190
|
+
*/
|
|
182
191
|
exports.secondFactorSignInRequestSchema = zod_1.z
|
|
183
192
|
.object({
|
|
184
193
|
challengeId: opaqueTokenSchema,
|
|
185
194
|
code: exports.secondFactorCodeSchema,
|
|
186
195
|
...sessionEnvelope,
|
|
196
|
+
platformClient: platformSession_1.platformClientSchema.optional(),
|
|
187
197
|
})
|
|
188
198
|
.strict();
|
|
189
199
|
/** `POST /auth/signup` — the account, from a username and a confirmed email. */
|
|
@@ -25,6 +25,7 @@ import { isoDateTime, utf16MaxLength, utf16MinLength } from './stringChecks.js';
|
|
|
25
25
|
*/
|
|
26
26
|
import { z } from 'zod';
|
|
27
27
|
import { APP_ASSERTION_CHALLENGE_PURPOSES, APP_ASSERTION_ERROR_CODES, APP_ASSERTION_PLATFORMS, OXY_APP_ASSERTION_AUDIENCE, OXY_APP_ASSERTION_HEADER, OXY_APP_ASSERTION_TTL_SECONDS, OXY_APP_ASSERTION_TYPE, } from './client/appAssertions.js';
|
|
28
|
+
import { OXYOS_DESKTOP_ENTRY_ID_PATTERN, PLATFORM_HOSTS } from './client/platformSession.js';
|
|
28
29
|
export { APP_ASSERTION_CHALLENGE_PURPOSES, APP_ASSERTION_ERROR_CODES, APP_ASSERTION_PLATFORMS, OXY_APP_ASSERTION_AUDIENCE, OXY_APP_ASSERTION_HEADER, OXY_APP_ASSERTION_TTL_SECONDS, OXY_APP_ASSERTION_TYPE, };
|
|
29
30
|
const applicationIdSchema = z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(255));
|
|
30
31
|
const base64Url32Schema = z.string().regex(/^[A-Za-z0-9_-]{43}$/);
|
|
@@ -34,6 +35,8 @@ const base64Schema = (max) => z
|
|
|
34
35
|
.check(utf16MaxLength(max))
|
|
35
36
|
.regex(/^[A-Za-z0-9+/]+={0,2}$/);
|
|
36
37
|
export const appAssertionPlatformSchema = z.enum(APP_ASSERTION_PLATFORMS);
|
|
38
|
+
/** A platform that holds the Oxy session for the applications it runs (ADR 0058). */
|
|
39
|
+
export const platformHostSchema = z.enum(PLATFORM_HOSTS);
|
|
37
40
|
export const appAssertionErrorCodeSchema = z.enum(APP_ASSERTION_ERROR_CODES);
|
|
38
41
|
// ---------------------------------------------------------------------------
|
|
39
42
|
// Registry
|
|
@@ -69,6 +72,11 @@ export const appleBundleIdSchema = z
|
|
|
69
72
|
.string()
|
|
70
73
|
.check(utf16MaxLength(255))
|
|
71
74
|
.regex(/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/, 'Must be an Apple bundle id');
|
|
75
|
+
/** An OxyOS desktop entry id (`so.oxy.dropsea`), the id OxyOS launches the application by. */
|
|
76
|
+
export const oxyosDesktopEntryIdSchema = z
|
|
77
|
+
.string()
|
|
78
|
+
.check(utf16MaxLength(255))
|
|
79
|
+
.regex(OXYOS_DESKTOP_ENTRY_ID_PATTERN, 'Must be an OxyOS desktop entry id');
|
|
72
80
|
const unique = (values) => new Set(values).size === values.length;
|
|
73
81
|
export const applicationAndroidRecognitionSchema = z
|
|
74
82
|
.object({
|
|
@@ -83,9 +91,22 @@ export const applicationAndroidRecognitionSchema = z
|
|
|
83
91
|
export const applicationIosRecognitionSchema = z
|
|
84
92
|
.object({ teamId: appleTeamIdSchema, bundleId: appleBundleIdSchema })
|
|
85
93
|
.strict();
|
|
94
|
+
const oxyosDesktopEntryIdsSchema = z
|
|
95
|
+
.array(oxyosDesktopEntryIdSchema)
|
|
96
|
+
.max(20)
|
|
97
|
+
.refine(unique, 'Desktop entry ids must be unique');
|
|
86
98
|
/**
|
|
87
99
|
* What Oxy staff write for an application: the whole declaration, replaced at
|
|
88
100
|
* once. `null` and `[]` declare nothing for that platform.
|
|
101
|
+
*
|
|
102
|
+
* ADR 0058 adds two fields a writer may omit, and an omitted one is left as
|
|
103
|
+
* the registry holds it (a writer that predates them cannot erase them):
|
|
104
|
+
*
|
|
105
|
+
* - `platformHost`: this application IS a platform that holds the Oxy session
|
|
106
|
+
* (OxyOS, Astro). Its public client id is the one a platform's own sign-in
|
|
107
|
+
* names (`platformClient`), and only an Oxy application may declare it.
|
|
108
|
+
* - `oxyosDesktopEntryIds`: the OxyOS desktop entry ids that launch this
|
|
109
|
+
* application, each naming one application only, as a web origin does.
|
|
89
110
|
*/
|
|
90
111
|
export const applicationRecognitionWriteSchema = z
|
|
91
112
|
.object({
|
|
@@ -95,12 +116,16 @@ export const applicationRecognitionWriteSchema = z
|
|
|
95
116
|
.refine(unique, 'Origins must be unique'),
|
|
96
117
|
android: applicationAndroidRecognitionSchema.nullable(),
|
|
97
118
|
ios: applicationIosRecognitionSchema.nullable(),
|
|
119
|
+
platformHost: platformHostSchema.nullable().optional(),
|
|
120
|
+
oxyosDesktopEntryIds: oxyosDesktopEntryIdsSchema.optional(),
|
|
98
121
|
})
|
|
99
122
|
.strict();
|
|
100
123
|
/** An application's recognition as the registry holds it; `updatedAt` is `null` when none was written. */
|
|
101
124
|
export const applicationRecognitionSchema = applicationRecognitionWriteSchema
|
|
102
125
|
.extend({
|
|
103
126
|
applicationId: applicationIdSchema,
|
|
127
|
+
platformHost: platformHostSchema.nullable(),
|
|
128
|
+
oxyosDesktopEntryIds: oxyosDesktopEntryIdsSchema,
|
|
104
129
|
updatedAt: z.string().check(isoDateTime()).nullable(),
|
|
105
130
|
})
|
|
106
131
|
.strict();
|
|
@@ -151,10 +176,14 @@ export const appAttestKeyResponseSchema = z.object({ keyId: appAttestKeyIdSchema
|
|
|
151
176
|
* `POST /apps/assertions`. The body names the application and the platform;
|
|
152
177
|
* the proof is the platform's: none on the web (the browser's `Origin` is), a
|
|
153
178
|
* Play Integrity token on Android, an App Attest assertion on iOS, each over a
|
|
154
|
-
* challenge minted for `assertion`.
|
|
179
|
+
* challenge minted for `assertion`. On `oxyos` and `astro` the bearer is the
|
|
180
|
+
* proof: an application token that platform minted for this application
|
|
181
|
+
* (ADR 0058).
|
|
155
182
|
*/
|
|
156
183
|
export const appAssertionRequestSchema = z.discriminatedUnion('platform', [
|
|
157
184
|
z.object({ applicationId: applicationIdSchema, platform: z.literal('web') }).strict(),
|
|
185
|
+
z.object({ applicationId: applicationIdSchema, platform: z.literal('oxyos') }).strict(),
|
|
186
|
+
z.object({ applicationId: applicationIdSchema, platform: z.literal('astro') }).strict(),
|
|
158
187
|
z
|
|
159
188
|
.object({
|
|
160
189
|
applicationId: applicationIdSchema,
|
|
@@ -10,8 +10,12 @@
|
|
|
10
10
|
* Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
|
|
11
11
|
*/
|
|
12
12
|
import { datetime, exact, oneOf, optional, pattern, strictObject, string } from './check.js';
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* How an app proves itself: the browser's origin, Play Integrity, App Attest,
|
|
15
|
+
* or (`oxyos`, `astro`) an application token the platform holding the session
|
|
16
|
+
* minted for it (ADR 0058), whose bearer is the proof.
|
|
17
|
+
*/
|
|
18
|
+
export const APP_ASSERTION_PLATFORMS = ['web', 'android', 'ios', 'oxyos', 'astro'];
|
|
15
19
|
/**
|
|
16
20
|
* What a device challenge is spent on: an assertion, or (iOS only) registering
|
|
17
21
|
* an App Attest key. A challenge minted for one is refused for the other.
|
|
@@ -42,6 +46,9 @@ export const OXY_APP_ASSERTION_TTL_SECONDS = 300;
|
|
|
42
46
|
* - `attestation_invalid`: the App Attest attestation does not verify.
|
|
43
47
|
* - `assertion_invalid`: the App Attest assertion does not verify, or its counter did not advance.
|
|
44
48
|
* - `signing_unavailable`: Oxy cannot sign (503).
|
|
49
|
+
* - `app_token_mismatch`: an `oxyos` or `astro` assertion needs an application token that
|
|
50
|
+
* platform minted for this application; an application token gets an assertion for its own
|
|
51
|
+
* application and platform only.
|
|
45
52
|
*/
|
|
46
53
|
export const APP_ASSERTION_ERROR_CODES = [
|
|
47
54
|
'application_unavailable',
|
|
@@ -57,6 +64,7 @@ export const APP_ASSERTION_ERROR_CODES = [
|
|
|
57
64
|
'attestation_invalid',
|
|
58
65
|
'assertion_invalid',
|
|
59
66
|
'signing_unavailable',
|
|
67
|
+
'app_token_mismatch',
|
|
60
68
|
];
|
|
61
69
|
/** 32 random bytes, base64url: a challenge, or the SHA-256 it is bound into. */
|
|
62
70
|
const BASE64URL_32 = /^[A-Za-z0-9_-]{43}$/;
|
package/dist/esm/client/index.js
CHANGED
|
@@ -43,6 +43,7 @@ export { userNameCheck, PROFILE_LINKS_MAX, PROFILE_LINK_TITLE_MAX } from './user
|
|
|
43
43
|
export { PRONOUNS } from './userResponse.js';
|
|
44
44
|
export { CLAIMANT_RELATIONSHIPS, CLOSED_CONTENT_CLAIM_STATES, CONTENT_CLAIM_COUNTER_NOTICE_LIMITS, CONTENT_CLAIM_ERROR_CODES, CONTENT_CLAIM_KINDS, CONTENT_CLAIM_LIMITS, CONTENT_CLAIM_REFERENCE_PATTERN, CONTENT_CLAIM_STATES, COUNTER_NOTICE_STATEMENT_VERSION, COUNTER_NOTICE_STATEMENTS, ERASURE_REQUEST_DEADLINE_DAYS, OPEN_CONTENT_CLAIM_STATES, isErasureRequest, isRightsClaim, } from './contentClaims.js';
|
|
45
45
|
export { APP_ASSERTION_CHALLENGE_PURPOSES, APP_ASSERTION_ERROR_CODES, APP_ASSERTION_PLATFORMS, OXY_APP_ASSERTION_AUDIENCE, OXY_APP_ASSERTION_HEADER, OXY_APP_ASSERTION_TTL_SECONDS, OXY_APP_ASSERTION_TYPE, appAssertionChallengeResponseCheck, appAssertionResponseCheck, appAttestKeyResponseCheck, } from './appAssertions.js';
|
|
46
|
+
export { APP_TOKEN_DEVICE_ACCESS_DENIED, DEVICE_APP_TOKEN_ERROR_CODES, DEVICE_APP_TOKEN_TTL_SECONDS, OXYOS_DESKTOP_ENTRY_ID_PATTERN, PLATFORM_HOSTS, deviceAppTokenResponseCheck, } from './platformSession.js';
|
|
46
47
|
export { USER_PROFILE_COLORS, USER_PROFILE_COLOR_PRESETS, FREE_USER_PROFILE_COLOR_PRESETS, } from '../profileColors.generated.js';
|
|
47
48
|
export * from '../products/one.js';
|
|
48
49
|
export { CAMPAIGN_LABEL_MAX_LENGTH, CAMPAIGN_CLICK_ID_MAX_LENGTH, hasCampaignControlCharacters, } from './campaignAttribution.js';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A platform that holds the Oxy session (ADR 0058), without Zod. Schemas:
|
|
3
|
+
* `../platformSession.ts`.
|
|
4
|
+
*
|
|
5
|
+
* OxyOS and Astro hold the person's Oxy session themselves, on a PLATFORM
|
|
6
|
+
* CREDENTIAL, and ask Oxy for a short token named for each application they
|
|
7
|
+
* run (`POST /session/device/app-token`). Applications hold no credential.
|
|
8
|
+
*
|
|
9
|
+
* Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
|
|
10
|
+
*/
|
|
11
|
+
import { datetime, exact, minLength, object, string } from './check.js';
|
|
12
|
+
/** The platforms that hold the Oxy session for the applications they run. */
|
|
13
|
+
export const PLATFORM_HOSTS = ['oxyos', 'astro'];
|
|
14
|
+
/**
|
|
15
|
+
* An OxyOS desktop entry id (`so.oxy.dropsea`): the reverse-DNS id OxyOS names
|
|
16
|
+
* an application by in its registry and launch records. Lowercase, at least two
|
|
17
|
+
* segments, unique across applications like a web origin.
|
|
18
|
+
*/
|
|
19
|
+
export const OXYOS_DESKTOP_ENTRY_ID_PATTERN = /^[a-z0-9]+(\.[a-z0-9-]+)+$/;
|
|
20
|
+
/** An application token lives exactly this long (ADR 0058 2.3). */
|
|
21
|
+
export const DEVICE_APP_TOKEN_TTL_SECONDS = 300;
|
|
22
|
+
/**
|
|
23
|
+
* Why `POST /session/device/app-token` refused. The API answers `{ error: <code> }`.
|
|
24
|
+
*
|
|
25
|
+
* - `invalid_request` (400): the body is not the contract's.
|
|
26
|
+
* - `browser_not_allowed` (403): the request carries a web `Origin` (or
|
|
27
|
+
* `Sec-Fetch-Site`); only a platform's own native service mints.
|
|
28
|
+
* - `invalid_device_secret` (401): the secret proves no PLATFORM credential of
|
|
29
|
+
* that device. A wrong secret counts toward the device-secret lockout.
|
|
30
|
+
* - `application_not_recognised` (403): the credential is another platform's,
|
|
31
|
+
* or the attestation names no active Oxy application recognised for this
|
|
32
|
+
* platform (an unknown desktop entry id, an origin that is not the
|
|
33
|
+
* application's, auth.oxy.so's application, a third-party application, a
|
|
34
|
+
* `clientId` of another application).
|
|
35
|
+
* - `no_active_session` / `account_not_on_device` (401): as
|
|
36
|
+
* `POST /session/device/token`: nothing live to mint for, or the pinned
|
|
37
|
+
* account is not live on the device.
|
|
38
|
+
*/
|
|
39
|
+
export const DEVICE_APP_TOKEN_ERROR_CODES = [
|
|
40
|
+
'invalid_request',
|
|
41
|
+
'browser_not_allowed',
|
|
42
|
+
'invalid_device_secret',
|
|
43
|
+
'application_not_recognised',
|
|
44
|
+
'no_active_session',
|
|
45
|
+
'account_not_on_device',
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* Every bearer-authenticated `/session/device/*` route answers an application
|
|
49
|
+
* token (one carrying `host`) with `403 { error: APP_TOKEN_DEVICE_ACCESS_DENIED }`:
|
|
50
|
+
* the device is the platform's, never an application's.
|
|
51
|
+
*/
|
|
52
|
+
export const APP_TOKEN_DEVICE_ACCESS_DENIED = 'app_token_device_access_denied';
|
|
53
|
+
export const deviceAppTokenResponseCheck = exact()(object({
|
|
54
|
+
accessToken: string(minLength(1)),
|
|
55
|
+
expiresAt: string(datetime),
|
|
56
|
+
applicationId: string(minLength(1)),
|
|
57
|
+
accountId: string(minLength(1)),
|
|
58
|
+
}));
|
package/dist/esm/index.js
CHANGED
|
@@ -211,6 +211,7 @@ export * from './serviceToken.js';
|
|
|
211
211
|
export * from './applicationRoles.js';
|
|
212
212
|
export * from './contentClaims.js';
|
|
213
213
|
export * from './appAssertions.js';
|
|
214
|
+
export * from './platformSession.js';
|
|
214
215
|
export * from './products/one.js';
|
|
215
216
|
export { USER_PROFILE_COLORS, USER_PROFILE_COLOR_PRESETS, FREE_USER_PROFILE_COLOR_PRESETS, } from './profileColors.generated.js';
|
|
216
217
|
export { utf16MinLength, utf16MaxLength, utf16Length, isoDateTime, urlCheck, } from './stringChecks.js';
|