@arcblock/did-connect-service 4.1.55 → 4.1.57

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.
Files changed (65) hide show
  1. package/dist/blocklet-service.d.ts +5 -0
  2. package/dist/blocklet-service.d.ts.map +1 -1
  3. package/dist/blocklet-service.js +4 -0
  4. package/dist/blocklet-service.js.map +1 -1
  5. package/dist/handlers/auth-handler.d.ts +5 -0
  6. package/dist/handlers/auth-handler.d.ts.map +1 -1
  7. package/dist/handlers/auth-handler.js +15 -14
  8. package/dist/handlers/auth-handler.js.map +1 -1
  9. package/dist/handlers/did-connect-handler.d.ts +2 -0
  10. package/dist/handlers/did-connect-handler.d.ts.map +1 -1
  11. package/dist/handlers/did-connect-handler.js +6 -4
  12. package/dist/handlers/did-connect-handler.js.map +1 -1
  13. package/dist/handlers/email-login-handler.d.ts +2 -0
  14. package/dist/handlers/email-login-handler.d.ts.map +1 -1
  15. package/dist/handlers/email-login-handler.js +11 -8
  16. package/dist/handlers/email-login-handler.js.map +1 -1
  17. package/dist/handlers/oauth-handler.d.ts +2 -0
  18. package/dist/handlers/oauth-handler.d.ts.map +1 -1
  19. package/dist/handlers/oauth-handler.js +28 -30
  20. package/dist/handlers/oauth-handler.js.map +1 -1
  21. package/dist/handlers/passkey-handler.d.ts +12 -3
  22. package/dist/handlers/passkey-handler.d.ts.map +1 -1
  23. package/dist/handlers/passkey-handler.js +44 -18
  24. package/dist/handlers/passkey-handler.js.map +1 -1
  25. package/dist/handlers/team-handler.d.ts.map +1 -1
  26. package/dist/handlers/team-handler.js +8 -3
  27. package/dist/handlers/team-handler.js.map +1 -1
  28. package/dist/handlers/ticket-handler.d.ts +2 -0
  29. package/dist/handlers/ticket-handler.d.ts.map +1 -1
  30. package/dist/handlers/ticket-handler.js +8 -10
  31. package/dist/handlers/ticket-handler.js.map +1 -1
  32. package/dist/identity/session-cookie.d.ts +17 -0
  33. package/dist/identity/session-cookie.d.ts.map +1 -1
  34. package/dist/identity/session-cookie.js +41 -0
  35. package/dist/identity/session-cookie.js.map +1 -1
  36. package/dist/og/generator.d.ts +13 -0
  37. package/dist/og/generator.d.ts.map +1 -1
  38. package/dist/og/generator.js +19 -5
  39. package/dist/og/generator.js.map +1 -1
  40. package/dist/og/index.d.ts +4 -2
  41. package/dist/og/index.d.ts.map +1 -1
  42. package/dist/og/index.js +2 -1
  43. package/dist/og/index.js.map +1 -1
  44. package/dist/og/node-config.d.ts +2 -0
  45. package/dist/og/node-config.d.ts.map +1 -1
  46. package/dist/og/node-config.js +1 -0
  47. package/dist/og/node-config.js.map +1 -1
  48. package/dist/og/node-wasm-fallback.d.ts.map +1 -1
  49. package/dist/og/node-wasm-fallback.js +12 -5
  50. package/dist/og/node-wasm-fallback.js.map +1 -1
  51. package/dist/og/tree-node.d.ts +73 -0
  52. package/dist/og/tree-node.d.ts.map +1 -0
  53. package/dist/og/tree-node.js +192 -0
  54. package/dist/og/tree-node.js.map +1 -0
  55. package/dist/og/tree.d.ts +192 -0
  56. package/dist/og/tree.d.ts.map +1 -0
  57. package/dist/og/tree.js +921 -0
  58. package/dist/og/tree.js.map +1 -0
  59. package/dist/og/worker.d.ts +74 -2
  60. package/dist/og/worker.d.ts.map +1 -1
  61. package/dist/og/worker.js +194 -57
  62. package/dist/og/worker.js.map +1 -1
  63. package/dist/types.d.ts +6 -0
  64. package/dist/types.d.ts.map +1 -1
  65. package/package.json +3 -3
@@ -0,0 +1,192 @@
1
+ /**
2
+ * Runtime-neutral half of the tree renderer (`renderOgTree`, ArcBlock/did#300).
3
+ *
4
+ * A caller hands in a plain satori object tree (the same `{ type, props }`
5
+ * shape `templates.ts` builds). Before anything is parsed or rasterized, this
6
+ * module walks the whole tree and enforces the image contract:
7
+ *
8
+ * - every image reference (`src`, `href`, any `url(...)` in a style or other
9
+ * prop) must be a `data:` URI — anything else rejects the WHOLE render and
10
+ * no request is ever made (keeps did#220's no-remote-media stance);
11
+ * - the bytes must be PNG / JPEG / SVG by magic bytes, matching the declared
12
+ * MIME type;
13
+ * - hard limits are read from the image headers (never by decoding):
14
+ * PNG/JPEG ≤ 1.5 MP and ≤ 1 MB each, SVG ≤ 256 KB, the whole tree
15
+ * ≤ 2.5 MP and ≤ 2 MB of raw image bytes. Nothing is resized; an
16
+ * over-limit tree is refused with a code that names the reason.
17
+ *
18
+ * Both runtime entries (`worker.ts` → `og-worker`, `tree-node.ts` → `og-node`)
19
+ * call {@link validateOgTree} and share {@link createSerialQueue}.
20
+ */
21
+ import { OgValidationError } from "./types.js";
22
+ /** Font weights a tree may declare. Fonts are loaded by the renderer per locale. */
23
+ export type OgTreeWeight = 400 | 700;
24
+ /** A satori node: `{ type, props }`, children under `props.children`. */
25
+ export interface OgTreeNode {
26
+ type: string;
27
+ props?: Record<string, unknown>;
28
+ }
29
+ export interface OgTreeRenderOptions {
30
+ /** Plain satori object tree. Only `data:` image URIs are accepted. */
31
+ tree: OgTreeNode;
32
+ width: number;
33
+ height: number;
34
+ /** BCP-47-ish locale; selects the font family (normalized like og.png). */
35
+ locale: string;
36
+ /** Weights the tree uses. Defaults to `[400]`. Regular is always loaded. */
37
+ weights?: readonly OgTreeWeight[];
38
+ }
39
+ /** Font family name trees should use in `fontFamily` (same as the templates). */
40
+ export declare const OG_TREE_FONT_FAMILY = "Noto";
41
+ export declare const OG_TREE_LIMITS: {
42
+ /** PNG/JPEG: max pixels per image. */
43
+ readonly maxImagePixels: 1500000;
44
+ /** PNG/JPEG: max raw bytes per image. */
45
+ readonly maxImageBytes: 1000000;
46
+ /** SVG: max raw bytes per image. */
47
+ readonly maxSvgBytes: number;
48
+ /** Sum of PNG/JPEG pixels over every image occurrence in the tree. */
49
+ readonly maxTotalPixels: 2500000;
50
+ /** Sum of raw image bytes (all types) over every image occurrence. */
51
+ readonly maxTotalBytes: 2000000;
52
+ /** Image occurrences per tree. */
53
+ readonly maxImages: 32;
54
+ /** Output canvas. */
55
+ readonly maxCanvasDimension: 2400;
56
+ readonly maxCanvasPixels: 1000000;
57
+ /** Tree shape. */
58
+ readonly maxDepth: 64;
59
+ readonly maxNodes: 5000;
60
+ /** Characters per text string (satori lays out every glyph). */
61
+ readonly maxStringChars: 2000;
62
+ /** Characters of text over the whole tree. */
63
+ readonly maxTextChars: 10000;
64
+ /** Characters per non-image prop string; inline `<svg>` props (path data) get more. */
65
+ readonly maxPropStringChars: 2000;
66
+ readonly maxSvgPropStringChars: 16384;
67
+ /** Characters over all non-image prop strings in the tree. */
68
+ readonly maxPropChars: 65536;
69
+ /** box-shadow / text-shadow: entries per value; |offset| per entry, in px. */
70
+ readonly maxShadows: 4;
71
+ readonly maxShadowLengthPx: 100;
72
+ /** Blur radius and spread for shadows, drop-shadow() and blur(), in px — blur drives render cost. */
73
+ readonly maxBlurPx: 16;
74
+ readonly maxSpreadPx: 16;
75
+ /** CSS filter: functions per value. */
76
+ readonly maxFilterFunctions: 4;
77
+ /**
78
+ * Tree-wide effect budget, in units. Render cost of a shadow or filter
79
+ * follows the AREA it covers, not its blur radius (measured on the Worker
80
+ * stack: a full-canvas box-shadow ≈ 0.4 s, a CSS filter on a full-canvas
81
+ * group ≈ 1.6 s at blur 4px and 16px alike). An element's area unit count
82
+ * is ceil(width × height / 250,000) from numeric px `width`/`height` in its
83
+ * style, or the whole canvas when either is not a number. Charges:
84
+ * - each boxShadow entry: 1 × area units;
85
+ * - each CSS filter function: 1 × area units, `blur()` 4 × area units (so a
86
+ * blur fits only on an element ≤ 250,000 px); filters are allowed only on
87
+ * elements without children (a filtered group rasterizes its whole,
88
+ * possibly overflowing, subtree: 6–8 s measured);
89
+ * - each textShadow entry: 1 per started 250 characters of every text
90
+ * string it reaches (textShadow is inherited, so a declaration on a
91
+ * container is paid for every text node below it).
92
+ * `drop-shadow()` is refused (use boxShadow).
93
+ */
94
+ readonly maxEffects: 4;
95
+ readonly effectAreaUnitPx: 250000;
96
+ readonly effectCostBlur: 4;
97
+ readonly textShadowCharsPerUnit: 250;
98
+ /** Inline <svg>: nodes and prop characters per tree (paths are costly to rasterize). */
99
+ readonly maxSvgNodes: 500;
100
+ readonly maxSvgChars: 16384;
101
+ };
102
+ export declare const OG_TREE_ERROR_CODES: {
103
+ readonly treeInvalid: "OG_TREE_INVALID";
104
+ readonly canvasInvalid: "OG_TREE_CANVAS_INVALID";
105
+ readonly weightsInvalid: "OG_TREE_WEIGHTS_INVALID";
106
+ readonly imageNotDataUri: "OG_IMAGE_NOT_DATA_URI";
107
+ readonly imageUnsupportedType: "OG_IMAGE_UNSUPPORTED_TYPE";
108
+ readonly imageUnreadable: "OG_IMAGE_UNREADABLE";
109
+ readonly imageTooManyPixels: "OG_IMAGE_TOO_MANY_PIXELS";
110
+ readonly imageTooLarge: "OG_IMAGE_TOO_LARGE";
111
+ readonly svgTooLarge: "OG_SVG_TOO_LARGE";
112
+ readonly svgUnsafe: "OG_SVG_UNSAFE";
113
+ readonly treeTooManyImages: "OG_TREE_TOO_MANY_IMAGES";
114
+ readonly treeTooManyPixels: "OG_TREE_TOO_MANY_PIXELS";
115
+ readonly treeTooManyBytes: "OG_TREE_TOO_MANY_BYTES";
116
+ readonly svgFilterForbidden: "OG_SVG_FILTER_FORBIDDEN";
117
+ readonly shadowLimit: "OG_TREE_SHADOW_LIMIT";
118
+ readonly cssFilterLimit: "OG_TREE_FILTER_LIMIT";
119
+ readonly textTooLong: "OG_TREE_TEXT_TOO_LONG";
120
+ /** satori/resvg failed on a tree that passed validation (generic; no input echoed). */
121
+ readonly renderFailed: "OG_TREE_RENDER_FAILED";
122
+ };
123
+ export type OgTreeErrorCode = (typeof OG_TREE_ERROR_CODES)[keyof typeof OG_TREE_ERROR_CODES];
124
+ /** Rejection of a tree render. `statusCode` 400 (inherited): the input is at fault. */
125
+ export declare class OgTreeRenderError extends OgValidationError {
126
+ readonly code: OgTreeErrorCode;
127
+ constructor(code: OgTreeErrorCode, message: string);
128
+ }
129
+ export declare const OG_RENDER_UNAVAILABLE_CODES: {
130
+ /** A font read did not finish within the timeout; the cached slot was dropped. */
131
+ readonly fontTimeout: "OG_FONT_TIMEOUT";
132
+ /** The render waited in the isolate/process queue past its deadline. */
133
+ readonly queueTimeout: "OG_QUEUE_TIMEOUT";
134
+ };
135
+ export type OgRenderUnavailableCode = (typeof OG_RENDER_UNAVAILABLE_CODES)[keyof typeof OG_RENDER_UNAVAILABLE_CODES];
136
+ /** The renderer is temporarily unable to serve (font storage hung, queue backed up). Retryable: 503. */
137
+ export declare class OgRenderUnavailableError extends Error {
138
+ readonly statusCode = 503;
139
+ readonly code: OgRenderUnavailableCode;
140
+ constructor(code: OgRenderUnavailableCode, message: string);
141
+ }
142
+ /** Rejects with `onTimeout()` if `promise` has not settled within `ms`. */
143
+ export declare function withTimeout<T>(promise: Promise<T>, ms: number, onTimeout: () => Error): Promise<T>;
144
+ export type OgImageKind = "png" | "jpeg" | "svg";
145
+ /** Detects PNG / JPEG / SVG from the bytes themselves; anything else is `undefined`. */
146
+ export declare function sniffOgImageKind(bytes: Uint8Array): OgImageKind | undefined;
147
+ export declare function ogImageMime(kind: OgImageKind): string;
148
+ export interface OgTreeImageStats {
149
+ imageCount: number;
150
+ totalPixels: number;
151
+ totalBytes: number;
152
+ }
153
+ /**
154
+ * Validates a tree render request without rendering. Throws an
155
+ * {@link OgTreeRenderError} naming the first violated rule; never performs I/O.
156
+ */
157
+ export declare function validateOgTree(options: OgTreeRenderOptions): OgTreeImageStats;
158
+ /** Validation for the renderers: returns the snapshot that was validated — render exactly this. */
159
+ export declare function prepareOgTree(options: OgTreeRenderOptions): OgTreeNode;
160
+ export type OgImageInspection = {
161
+ kind: OgImageKind;
162
+ width: number | null;
163
+ height: number | null;
164
+ bytes: number;
165
+ } | {
166
+ code: OgTreeErrorCode;
167
+ };
168
+ /**
169
+ * Checks ONE image data: URI against the per-image rules (type, bytes, pixels,
170
+ * SVG safety) without rendering, so a caller can drop an image before building
171
+ * a tree. `width`/`height` are null for SVG. Tree-wide totals are not applied.
172
+ */
173
+ export declare function inspectOgImage(dataUri: string): OgImageInspection;
174
+ export declare function wantsBold(weights: readonly OgTreeWeight[] | undefined): boolean;
175
+ export interface SerialTaskInfo {
176
+ /** Milliseconds the task waited in the queue before starting. */
177
+ queueMs: number;
178
+ }
179
+ export type SerialQueue = <T>(task: (info: SerialTaskInfo) => Promise<T>, options?: {
180
+ maxWaitMs?: number;
181
+ }) => Promise<T>;
182
+ /**
183
+ * A FIFO mutex: a task starts only after every previously queued task has
184
+ * settled (fulfilled or rejected). One queue per isolate/process keeps
185
+ * satori's per-render font parse and resvg's wasm heap from stacking.
186
+ *
187
+ * `maxWaitMs`: a task still waiting when the deadline passes is rejected with
188
+ * an {@link OgRenderUnavailableError} (`OG_QUEUE_TIMEOUT`) and never runs, so a
189
+ * wedged predecessor cannot pile up callers forever.
190
+ */
191
+ export declare function createSerialQueue(): SerialQueue;
192
+ //# sourceMappingURL=tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/og/tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,oFAAoF;AACpF,MAAM,MAAM,YAAY,GAAG,GAAG,GAAG,GAAG,CAAC;AAErC,yEAAyE;AACzE,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,OAAO,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;CACnC;AAED,iFAAiF;AACjF,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAE1C,eAAO,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