@orangecheck/me-client 0.49.0 → 0.51.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/CHANGELOG.md +738 -0
- package/README.md +13 -9
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -1
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +22 -5
- package/dist/server.d.ts +22 -5
- package/dist/server.js +55 -9
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +55 -9
- package/dist/server.mjs.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -281,24 +281,28 @@ Set `OC_PROJECT_KEY` and `OC_SIGNING_SECRET` (from ochk.app/me/projects) and `ge
|
|
|
281
281
|
|
|
282
282
|
### Sign in from an app on the person's device
|
|
283
283
|
|
|
284
|
-
A desktop build or a game can't open the popup, and must not carry a secret. It signs the person in through their browser instead (0.
|
|
284
|
+
A desktop build or a game can't open the popup, and must not carry a secret. It signs the person in through their browser instead (0.50.0, test projects only for now): the app listens on `127.0.0.1`, opens ochk.io's `/native/authorize` with a PKCE challenge, and its listener receives a one-time `code`. The app hands the code, its verifier and its redirect to your server, which trades them:
|
|
285
285
|
|
|
286
286
|
```ts
|
|
287
287
|
import { exchangeNativeCode, spendOnce } from '@orangecheck/me-client/server';
|
|
288
288
|
|
|
289
|
-
const out = await exchangeNativeCode(
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
289
|
+
const out = await exchangeNativeCode(
|
|
290
|
+
{
|
|
291
|
+
code,
|
|
292
|
+
codeVerifier,
|
|
293
|
+
redirectUri, // exactly as the app sent it: http://127.0.0.1:<port>/<path>
|
|
294
|
+
audience: 'https://your-site.example', // your verified domain, or your test project's dev origin
|
|
295
|
+
},
|
|
296
|
+
{ projectKey: process.env.OC_PROJECT_KEY } // your own key, from your config, never from the request
|
|
297
|
+
);
|
|
296
298
|
if (out.status === 'valid' && (await spendOnce(out.session.jti, out.session.exp ?? 0, store))) {
|
|
297
299
|
// Start your session for out.session.did_oc.
|
|
298
300
|
}
|
|
299
301
|
```
|
|
300
302
|
|
|
301
|
-
|
|
303
|
+
Start a session only from `valid`. It means what a request through `withOcAuth` means: the token is the popup's, verified for your `audience`, with `azp: "native"`; the person has not ended it everywhere; and the account meets your project's "who can sign in" rule. The key decides whose rule and list of ended sessions apply, so it comes from your config (`projectKey`, default `OC_PROJECT_KEY`), and a `projectKey` in the input throws. The list of ended sessions is read with your project key and `OC_SIGNING_SECRET`, as the adapters read it, or pass `revocation`; the trade counts as a write, so a list that can't be read answers `unavailable`.
|
|
304
|
+
|
|
305
|
+
`invalid` names why: `invalid_grant` (start again), `session_ended`, or `bond_required` with `need`, `have` and `back_url`, as the adapters' 403 carries them. `unavailable` is an outage (`revocations_unavailable` and `bond_policy_unavailable` among them), so answer it 503. Each code works once, whatever the answer. Turn native sign-in on for a test project on ochk.app; the app's half, with a Godot example, is at ochk.io/docs/integration/native-sign-in.
|
|
302
306
|
|
|
303
307
|
## Keep your own login: OC Connect
|
|
304
308
|
|
package/dist/index.d.mts
CHANGED
|
@@ -219,6 +219,8 @@ declare const federations: {
|
|
|
219
219
|
defaultLive: typeof defaultLive;
|
|
220
220
|
};
|
|
221
221
|
|
|
222
|
+
declare function safeReturnPath(raw: unknown, fallback?: string): string;
|
|
223
|
+
|
|
222
224
|
declare function setOrigin(url: string): void;
|
|
223
225
|
declare function getOrigin(): string;
|
|
224
226
|
declare function setBearerToken(token: string | null): void;
|
|
@@ -287,4 +289,4 @@ declare const oc: {
|
|
|
287
289
|
};
|
|
288
290
|
};
|
|
289
291
|
|
|
290
|
-
export { ArchetypeTemplate, type BatchEventResult, BillableEvent, EventKey, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, Federation, type FireBatchResponse, type FireEventOptions, type FireEventResult, type GrantedOptions, type GrantedResult, IntegratorPriceConfig, MeClientError, type OcPublicJwk, type PayPeriod, type PayingState, PaymentAuthorizeOptions, PaymentResult, type RequestOptions, type Scope, Session, SignInOptions, TelemetryEvent, type TrustAttestationCount, ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WithRateLimitRetryOptions, clearBearerToken, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, oc, onTelemetry, parseTrustAttestationCount, payingAt, payment, refreshEnvelopeJwks, scope, session, setBearerToken, setOrigin, verifyActivityAttestation, webhook, withRateLimitRetry };
|
|
292
|
+
export { ArchetypeTemplate, type BatchEventResult, BillableEvent, EventKey, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, Federation, type FireBatchResponse, type FireEventOptions, type FireEventResult, type GrantedOptions, type GrantedResult, IntegratorPriceConfig, MeClientError, type OcPublicJwk, type PayPeriod, type PayingState, PaymentAuthorizeOptions, PaymentResult, type RequestOptions, type Scope, Session, SignInOptions, TelemetryEvent, type TrustAttestationCount, ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WithRateLimitRetryOptions, clearBearerToken, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, oc, onTelemetry, parseTrustAttestationCount, payingAt, payment, refreshEnvelopeJwks, safeReturnPath, scope, session, setBearerToken, setOrigin, verifyActivityAttestation, webhook, withRateLimitRetry };
|
package/dist/index.d.ts
CHANGED
|
@@ -219,6 +219,8 @@ declare const federations: {
|
|
|
219
219
|
defaultLive: typeof defaultLive;
|
|
220
220
|
};
|
|
221
221
|
|
|
222
|
+
declare function safeReturnPath(raw: unknown, fallback?: string): string;
|
|
223
|
+
|
|
222
224
|
declare function setOrigin(url: string): void;
|
|
223
225
|
declare function getOrigin(): string;
|
|
224
226
|
declare function setBearerToken(token: string | null): void;
|
|
@@ -287,4 +289,4 @@ declare const oc: {
|
|
|
287
289
|
};
|
|
288
290
|
};
|
|
289
291
|
|
|
290
|
-
export { ArchetypeTemplate, type BatchEventResult, BillableEvent, EventKey, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, Federation, type FireBatchResponse, type FireEventOptions, type FireEventResult, type GrantedOptions, type GrantedResult, IntegratorPriceConfig, MeClientError, type OcPublicJwk, type PayPeriod, type PayingState, PaymentAuthorizeOptions, PaymentResult, type RequestOptions, type Scope, Session, SignInOptions, TelemetryEvent, type TrustAttestationCount, ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WithRateLimitRetryOptions, clearBearerToken, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, oc, onTelemetry, parseTrustAttestationCount, payingAt, payment, refreshEnvelopeJwks, scope, session, setBearerToken, setOrigin, verifyActivityAttestation, webhook, withRateLimitRetry };
|
|
292
|
+
export { ArchetypeTemplate, type BatchEventResult, BillableEvent, EventKey, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, Federation, type FireBatchResponse, type FireEventOptions, type FireEventResult, type GrantedOptions, type GrantedResult, IntegratorPriceConfig, MeClientError, type OcPublicJwk, type PayPeriod, type PayingState, PaymentAuthorizeOptions, PaymentResult, type RequestOptions, type Scope, Session, SignInOptions, TelemetryEvent, type TrustAttestationCount, ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WithRateLimitRetryOptions, clearBearerToken, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, oc, onTelemetry, parseTrustAttestationCount, payingAt, payment, refreshEnvelopeJwks, safeReturnPath, scope, session, setBearerToken, setOrigin, verifyActivityAttestation, webhook, withRateLimitRetry };
|
package/dist/index.js
CHANGED
|
@@ -1220,6 +1220,30 @@ var family = { scopes };
|
|
|
1220
1220
|
var CONNECT_CONSENT_LABEL = "Also create my orangecheck account";
|
|
1221
1221
|
var CONNECT_CONSENT_BLURB = "It stays with orangecheck until you claim it at ochk.app. Then you can use it on other sites, or delete it.";
|
|
1222
1222
|
|
|
1223
|
+
// src/return-path.ts
|
|
1224
|
+
function safeReturnPath(raw, fallback = "/") {
|
|
1225
|
+
if (typeof raw !== "string" || raw.length === 0 || raw.length > 2048) return fallback;
|
|
1226
|
+
try {
|
|
1227
|
+
encodeURIComponent(raw);
|
|
1228
|
+
} catch {
|
|
1229
|
+
return fallback;
|
|
1230
|
+
}
|
|
1231
|
+
if (!raw.startsWith("/") || raw.startsWith("//") || raw.startsWith("/\\")) return fallback;
|
|
1232
|
+
if (/[\u0000-\u001f\u007f-\u009f\\]/.test(raw)) return fallback;
|
|
1233
|
+
try {
|
|
1234
|
+
decodeURIComponent(raw);
|
|
1235
|
+
} catch {
|
|
1236
|
+
return fallback;
|
|
1237
|
+
}
|
|
1238
|
+
const segments = raw.split(/[?#]/, 1)[0].split("/");
|
|
1239
|
+
if (segments.some((s) => /^(\.|%2e){1,2}$/i.test(s))) return fallback;
|
|
1240
|
+
try {
|
|
1241
|
+
return new URL(raw, "https://site.invalid").origin === "https://site.invalid" ? raw : fallback;
|
|
1242
|
+
} catch {
|
|
1243
|
+
return fallback;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1223
1247
|
// src/identity.ts
|
|
1224
1248
|
var DEFAULT_ISSUER2 = "https://me.ochk.io";
|
|
1225
1249
|
var DEFAULT_TTL_MS2 = 60 * 60 * 1e3;
|
|
@@ -1650,6 +1674,7 @@ exports.parseTrustAttestationCount = parseTrustAttestationCount;
|
|
|
1650
1674
|
exports.payingAt = payingAt;
|
|
1651
1675
|
exports.payment = payment;
|
|
1652
1676
|
exports.refreshEnvelopeJwks = refreshEnvelopeJwks;
|
|
1677
|
+
exports.safeReturnPath = safeReturnPath;
|
|
1653
1678
|
exports.scope = scope;
|
|
1654
1679
|
exports.session = session;
|
|
1655
1680
|
exports.setBearerToken = setBearerToken;
|