@smartcrab/contracts-public 0.2.1-next-20261009084044 → 0.3.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.
@@ -40,16 +40,13 @@ export declare const transactionCreateRequestSchema: z.ZodObject<{
40
40
  }, z.core.$strict>;
41
41
  export type TransactionCreateRequest = z.infer<typeof transactionCreateRequestSchema>;
42
42
  /**
43
- * ```json
44
- * {
45
- * "transaction_id": "txn_xxx",
46
- * "expires_at": "2026-08-02T08:10:00Z",
47
- * "available_methods": ["passkey", "google", "apple", "email_otp"]
48
- * }
49
- * ```
43
+ * The `transaction_secret` is a one-time 256-bit capability for the direct
44
+ * headless transaction flow. Store it securely and send it as
45
+ * `x-transaction-secret` on every transaction-scoped request.
50
46
  */
51
47
  export declare const transactionCreateResponseSchema: z.ZodObject<{
52
48
  transaction_id: z.ZodString;
49
+ transaction_secret: z.ZodString;
53
50
  expires_at: z.ZodISODateTime;
54
51
  available_methods: z.ZodArray<z.ZodEnum<{
55
52
  passkey: "passkey";
@@ -141,4 +138,9 @@ export declare const transactionCompleteResponseSchema: z.ZodObject<{
141
138
  state: z.ZodString;
142
139
  redirect_uri: z.ZodString;
143
140
  }, z.core.$strict>;
141
+ /** One-time callback result handle for Hosted Login's same-browser finish redirect. */
142
+ export declare const socialCallbackFinishQuerySchema: z.ZodObject<{
143
+ h: z.ZodString;
144
+ }, z.core.$strict>;
145
+ export type SocialCallbackFinishQuery = z.infer<typeof socialCallbackFinishQuerySchema>;
144
146
  export type TransactionCompleteResponse = z.infer<typeof transactionCompleteResponseSchema>;
@@ -37,16 +37,13 @@ export const transactionCreateRequestSchema = z.strictObject({
37
37
  response_mode: responseModeSchema.optional(),
38
38
  });
39
39
  /**
40
- * ```json
41
- * {
42
- * "transaction_id": "txn_xxx",
43
- * "expires_at": "2026-08-02T08:10:00Z",
44
- * "available_methods": ["passkey", "google", "apple", "email_otp"]
45
- * }
46
- * ```
40
+ * The `transaction_secret` is a one-time 256-bit capability for the direct
41
+ * headless transaction flow. Store it securely and send it as
42
+ * `x-transaction-secret` on every transaction-scoped request.
47
43
  */
48
44
  export const transactionCreateResponseSchema = z.strictObject({
49
45
  transaction_id: transactionIdSchema,
46
+ transaction_secret: z.string().regex(/^[A-Za-z0-9_-]{43}$/),
50
47
  expires_at: isoDateTimeSchema,
51
48
  available_methods: z.array(authMethodSchema),
52
49
  });
@@ -101,3 +98,7 @@ export const transactionCompleteResponseSchema = z.strictObject({
101
98
  state: opaqueClientValueSchema,
102
99
  redirect_uri: redirectUriSchema,
103
100
  });
101
+ /** One-time callback result handle for Hosted Login's same-browser finish redirect. */
102
+ export const socialCallbackFinishQuerySchema = z.strictObject({
103
+ h: z.string().regex(/^[A-Za-z0-9_-]{43}$/),
104
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartcrab/contracts-public",
3
- "version": "0.2.1-next-20261009084044",
3
+ "version": "0.3.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,8 +28,8 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "zod": "4.4.3",
31
- "@smartcrab/tenant-context": "0.2.1-next-20261009084044",
32
- "@smartcrab/identifiers": "0.2.1-next-20261009084044"
31
+ "@smartcrab/tenant-context": "0.3.0",
32
+ "@smartcrab/identifiers": "0.3.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "typescript": "5.9.3",
@@ -1,5 +1,6 @@
1
1
  import { describe, expect, test } from "vitest";
2
2
  import {
3
+ socialCallbackFinishQuerySchema,
3
4
  transactionCancelResponseSchema,
4
5
  transactionCompleteResponseSchema,
5
6
  transactionCreateRequestSchema,
@@ -62,22 +63,22 @@ describe("transactionCreateRequestSchema (design.md §16.1)", () => {
62
63
  });
63
64
 
64
65
  describe("transactionCreateResponseSchema (design.md §16.1)", () => {
65
- test("accepts the exact design example", () => {
66
+ test("accepts the one-time headless transaction secret", () => {
66
67
  const parsed = transactionCreateResponseSchema.safeParse({
67
68
  transaction_id: `txn_${"b".repeat(32)}`,
69
+ transaction_secret: "A".repeat(43),
68
70
  expires_at: "2026-08-02T08:10:00Z",
69
71
  available_methods: ["passkey", "google", "apple", "email_otp"],
70
72
  });
71
73
  expect(parsed.success).toBe(true);
72
- });
73
-
74
- test("rejects an unknown available method", () => {
75
- const parsed = transactionCreateResponseSchema.safeParse({
76
- transaction_id: `txn_${"b".repeat(32)}`,
77
- expires_at: "2026-08-02T08:10:00Z",
78
- available_methods: ["password"],
79
- });
80
- expect(parsed.success).toBe(false);
74
+ expect(
75
+ transactionCreateResponseSchema.safeParse({
76
+ transaction_id: `txn_${"b".repeat(32)}`,
77
+ transaction_secret: "invalid",
78
+ expires_at: "2026-08-02T08:10:00Z",
79
+ available_methods: ["passkey", "google", "apple", "email_otp"],
80
+ }).success,
81
+ ).toBe(false);
81
82
  });
82
83
  });
83
84
  describe("transactionGetResponseSchema (design.md §20.5)", () => {
@@ -115,6 +116,15 @@ describe("transactionGetResponseSchema (design.md §20.5)", () => {
115
116
  ).toBe(false);
116
117
  });
117
118
  });
119
+ describe("socialCallbackFinishQuerySchema", () => {
120
+ test("accepts only a base64url-encoded 256-bit one-time handle", () => {
121
+ expect(socialCallbackFinishQuerySchema.safeParse({ h: "A".repeat(43) }).success).toBe(true);
122
+ expect(socialCallbackFinishQuerySchema.safeParse({ h: "short" }).success).toBe(false);
123
+ expect(socialCallbackFinishQuerySchema.safeParse({ h: "A".repeat(42) + "!" }).success).toBe(
124
+ false,
125
+ );
126
+ });
127
+ });
118
128
 
119
129
  describe("transactionCompleteResponseSchema (design.md §16.3)", () => {
120
130
  test("accepts the exact design example", () => {
@@ -52,16 +52,13 @@ export const transactionCreateRequestSchema = z.strictObject({
52
52
  export type TransactionCreateRequest = z.infer<typeof transactionCreateRequestSchema>;
53
53
 
54
54
  /**
55
- * ```json
56
- * {
57
- * "transaction_id": "txn_xxx",
58
- * "expires_at": "2026-08-02T08:10:00Z",
59
- * "available_methods": ["passkey", "google", "apple", "email_otp"]
60
- * }
61
- * ```
55
+ * The `transaction_secret` is a one-time 256-bit capability for the direct
56
+ * headless transaction flow. Store it securely and send it as
57
+ * `x-transaction-secret` on every transaction-scoped request.
62
58
  */
63
59
  export const transactionCreateResponseSchema = z.strictObject({
64
60
  transaction_id: transactionIdSchema,
61
+ transaction_secret: z.string().regex(/^[A-Za-z0-9_-]{43}$/),
65
62
  expires_at: isoDateTimeSchema,
66
63
  available_methods: z.array(authMethodSchema),
67
64
  });
@@ -126,4 +123,9 @@ export const transactionCompleteResponseSchema = z.strictObject({
126
123
  state: opaqueClientValueSchema,
127
124
  redirect_uri: redirectUriSchema,
128
125
  });
126
+ /** One-time callback result handle for Hosted Login's same-browser finish redirect. */
127
+ export const socialCallbackFinishQuerySchema = z.strictObject({
128
+ h: z.string().regex(/^[A-Za-z0-9_-]{43}$/),
129
+ });
130
+ export type SocialCallbackFinishQuery = z.infer<typeof socialCallbackFinishQuerySchema>;
129
131
  export type TransactionCompleteResponse = z.infer<typeof transactionCompleteResponseSchema>;