@andco/protocol 0.0.1

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 (126) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +44 -0
  3. package/dist/authorization-preparation.d.ts +754 -0
  4. package/dist/authorization-preparation.d.ts.map +1 -0
  5. package/dist/authorization-preparation.js +187 -0
  6. package/dist/authorization.d.ts +99 -0
  7. package/dist/authorization.d.ts.map +1 -0
  8. package/dist/authorization.js +227 -0
  9. package/dist/automatic-charge.d.ts +314 -0
  10. package/dist/automatic-charge.d.ts.map +1 -0
  11. package/dist/automatic-charge.js +126 -0
  12. package/dist/bank-account-authorization.d.ts +6 -0
  13. package/dist/bank-account-authorization.d.ts.map +1 -0
  14. package/dist/bank-account-authorization.js +13 -0
  15. package/dist/callback-state.d.ts +10 -0
  16. package/dist/callback-state.d.ts.map +1 -0
  17. package/dist/callback-state.js +28 -0
  18. package/dist/consent.d.ts +48 -0
  19. package/dist/consent.d.ts.map +1 -0
  20. package/dist/consent.js +110 -0
  21. package/dist/constants.d.ts +17 -0
  22. package/dist/constants.d.ts.map +1 -0
  23. package/dist/constants.js +20 -0
  24. package/dist/errors.d.ts +70 -0
  25. package/dist/errors.d.ts.map +1 -0
  26. package/dist/errors.js +80 -0
  27. package/dist/index.d.ts +33 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +32 -0
  30. package/dist/intent-input.d.ts +637 -0
  31. package/dist/intent-input.d.ts.map +1 -0
  32. package/dist/intent-input.js +101 -0
  33. package/dist/messages/authorization-response.d.ts +12 -0
  34. package/dist/messages/authorization-response.d.ts.map +1 -0
  35. package/dist/messages/authorization-response.js +9 -0
  36. package/dist/messages/base.d.ts +31 -0
  37. package/dist/messages/base.d.ts.map +1 -0
  38. package/dist/messages/base.js +30 -0
  39. package/dist/messages/click.d.ts +11 -0
  40. package/dist/messages/click.d.ts.map +1 -0
  41. package/dist/messages/click.js +8 -0
  42. package/dist/messages/error.d.ts +13 -0
  43. package/dist/messages/error.d.ts.map +1 -0
  44. package/dist/messages/error.js +9 -0
  45. package/dist/messages/index.d.ts +75 -0
  46. package/dist/messages/index.d.ts.map +1 -0
  47. package/dist/messages/index.js +27 -0
  48. package/dist/messages/init.d.ts +9 -0
  49. package/dist/messages/init.d.ts.map +1 -0
  50. package/dist/messages/init.js +6 -0
  51. package/dist/messages/popup.d.ts +108 -0
  52. package/dist/messages/popup.d.ts.map +1 -0
  53. package/dist/messages/popup.js +62 -0
  54. package/dist/messages/ready.d.ts +9 -0
  55. package/dist/messages/ready.d.ts.map +1 -0
  56. package/dist/messages/ready.js +6 -0
  57. package/dist/messages/set-preferences.d.ts +16 -0
  58. package/dist/messages/set-preferences.d.ts.map +1 -0
  59. package/dist/messages/set-preferences.js +20 -0
  60. package/dist/miniapp-icon.d.ts +4 -0
  61. package/dist/miniapp-icon.d.ts.map +1 -0
  62. package/dist/miniapp-icon.js +68 -0
  63. package/dist/miniapp-manifest.d.ts +71 -0
  64. package/dist/miniapp-manifest.d.ts.map +1 -0
  65. package/dist/miniapp-manifest.js +46 -0
  66. package/dist/native-copy.d.ts +7 -0
  67. package/dist/native-copy.d.ts.map +1 -0
  68. package/dist/native-copy.js +436 -0
  69. package/dist/native-intent.d.ts +402 -0
  70. package/dist/native-intent.d.ts.map +1 -0
  71. package/dist/native-intent.js +410 -0
  72. package/dist/native.d.ts +55 -0
  73. package/dist/native.d.ts.map +1 -0
  74. package/dist/native.js +53 -0
  75. package/dist/oauth.d.ts +4 -0
  76. package/dist/oauth.d.ts.map +1 -0
  77. package/dist/oauth.js +3 -0
  78. package/dist/release.d.ts +3 -0
  79. package/dist/release.d.ts.map +1 -0
  80. package/dist/release.js +2 -0
  81. package/dist/scopes.d.ts +35 -0
  82. package/dist/scopes.d.ts.map +1 -0
  83. package/dist/scopes.js +15 -0
  84. package/dist/server.d.ts +9 -0
  85. package/dist/server.d.ts.map +1 -0
  86. package/dist/server.js +14 -0
  87. package/dist/transport/financial-events.d.ts +134 -0
  88. package/dist/transport/financial-events.d.ts.map +1 -0
  89. package/dist/transport/financial-events.js +120 -0
  90. package/dist/transport/generated/oauth-api.d.ts +1685 -0
  91. package/dist/transport/generated/oauth-api.d.ts.map +1 -0
  92. package/dist/transport/generated/oauth-api.js +5 -0
  93. package/dist/transport/index.d.ts +6 -0
  94. package/dist/transport/index.d.ts.map +1 -0
  95. package/dist/transport/index.js +5 -0
  96. package/dist/transport/intents.d.ts +81 -0
  97. package/dist/transport/intents.d.ts.map +1 -0
  98. package/dist/transport/intents.js +286 -0
  99. package/dist/transport/rest.d.ts +76 -0
  100. package/dist/transport/rest.d.ts.map +1 -0
  101. package/dist/transport/rest.js +48 -0
  102. package/dist/transport/runtime.d.ts +8 -0
  103. package/dist/transport/runtime.d.ts.map +1 -0
  104. package/dist/transport/runtime.js +16 -0
  105. package/dist/transport/webhooks.d.ts +27 -0
  106. package/dist/transport/webhooks.d.ts.map +1 -0
  107. package/dist/transport/webhooks.js +68 -0
  108. package/dist/urls.d.ts +71 -0
  109. package/dist/urls.d.ts.map +1 -0
  110. package/dist/urls.js +132 -0
  111. package/dist/userinfo.d.ts +11 -0
  112. package/dist/userinfo.d.ts.map +1 -0
  113. package/dist/userinfo.js +9 -0
  114. package/dist/utils.d.ts +20 -0
  115. package/dist/utils.d.ts.map +1 -0
  116. package/dist/utils.js +45 -0
  117. package/dist/webhook-input.d.ts +22 -0
  118. package/dist/webhook-input.d.ts.map +1 -0
  119. package/dist/webhook-input.js +11 -0
  120. package/dist/webhook-signature.d.ts +54 -0
  121. package/dist/webhook-signature.d.ts.map +1 -0
  122. package/dist/webhook-signature.js +74 -0
  123. package/dist/window-features.d.ts +28 -0
  124. package/dist/window-features.d.ts.map +1 -0
  125. package/dist/window-features.js +55 -0
  126. package/package.json +63 -0
@@ -0,0 +1,101 @@
1
+ import * as v from "valibot";
2
+ const text = (max) => v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(max));
3
+ const accountId = /* @__PURE__ */ v.pipe(v.string(), v.uuid());
4
+ const bankAccount = {
5
+ account_holder_id: text(64),
6
+ account_holder_name: text(256),
7
+ account_kind: v.picklist(["checking", "debit", "savings"]),
8
+ account_number: text(64),
9
+ bank_id: v.pipe(v.string(), v.regex(/^[a-z0-9][a-z0-9_-]{0,63}$/)),
10
+ country: v.literal("CL"),
11
+ };
12
+ const amount = {
13
+ currency: v.literal("CLP"),
14
+ editable: v.optional(v.boolean(), false),
15
+ suggested: v.pipe(v.string(), v.regex(/^[1-9][0-9]{0,15}$/), v.check((value) => Number.isSafeInteger(Number(value)))),
16
+ };
17
+ /** Validates fixed-duration syntax without anchoring it to a changing clock. */
18
+ export function isIntentDuration(value) {
19
+ const match = /^([1-9][0-9]*)\s+(seconds?|minutes?|hours?|days?)$/.exec(value.trim());
20
+ if (!match)
21
+ return false;
22
+ const unit = match[2]?.replace(/s$/, "");
23
+ const factor = unit === "day" ? 86400 : unit === "hour" ? 3600 : unit === "minute" ? 60 : 1;
24
+ const seconds = Number(match[1]) * factor;
25
+ return Number.isSafeInteger(seconds) && seconds <= 253402300799;
26
+ }
27
+ /** Validates a real ISO calendar datetime with a timezone; past dates remain valid for idempotent replay. */
28
+ export function isIntentDeadline(value) {
29
+ if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|[+-]\d{2}:\d{2})$/.test(value))
30
+ return false;
31
+ const date = value.slice(0, 10);
32
+ const midnight = new Date(`${date}T00:00:00Z`);
33
+ return (Number.isFinite(Date.parse(value)) &&
34
+ Number.isFinite(midnight.getTime()) &&
35
+ midnight.toISOString().slice(0, 10) === date);
36
+ }
37
+ const common = {
38
+ expires_in: v.optional(v.pipe(v.string(), v.check(isIntentDuration, "invalid_expiration_interval"))),
39
+ expires_at: v.optional(v.pipe(v.string(), v.check(isIntentDeadline, "invalid_expiration_datetime"))),
40
+ note: v.optional(v.strictObject({
41
+ suggested: v.pipe(v.string(), v.trim(), v.check((value) => [...value].length <= 140, "note_too_long")),
42
+ editable: v.optional(v.boolean(), false),
43
+ })),
44
+ metadata: v.optional(v.record(v.string(), v.unknown()), {}),
45
+ };
46
+ /** Public creation validation shared by the API and SDK. SQL resolves deadlines and enforces authorization. */
47
+ export const IntentCreateSchema = /* @__PURE__ */ v.pipe(v.variant("type", [
48
+ v.strictObject({
49
+ ...common,
50
+ type: v.literal("deposit"),
51
+ amount: v.optional(v.strictObject(amount)),
52
+ expires_at: v.optional(v.nullable(v.pipe(v.string(), v.check(isIntentDeadline, "invalid_expiration_datetime")))),
53
+ }),
54
+ v.strictObject({
55
+ ...common,
56
+ type: v.literal("withdrawal"),
57
+ amount: v.strictObject(amount),
58
+ source: v.optional(v.nullable(v.union([v.strictObject({ bank_account_id: accountId }), v.strictObject(bankAccount)])), null),
59
+ beneficiary: v.union([
60
+ v.strictObject({ ...bankAccount, editable: v.optional(v.boolean(), false) }),
61
+ v.strictObject({ bank_account_id: accountId, editable: v.optional(v.literal(false), false) }),
62
+ ]),
63
+ }),
64
+ v.strictObject({
65
+ ...common,
66
+ type: v.literal("automatic_charge"),
67
+ amount: v.strictObject({ ...amount, editable: v.optional(v.literal(false), false) }),
68
+ source: v.optional(v.nullable(v.strictObject({ bank_account_id: accountId })), null),
69
+ beneficiary: v.strictObject({ bank_account_id: accountId }),
70
+ }),
71
+ ]), v.check((input) => (input.expires_in !== undefined) !== (input.expires_at !== undefined), "exactly_one_expiration_required"), v.check((input) => input.expires_at !== null || (input.type === "deposit" && input.amount === undefined), "passive_deposit_requires_no_target"), v.check((input) => JSON.stringify(input.metadata).length <= 16384, "metadata_too_large"));
72
+ /** Returns validation issues without throwing across the HTTP boundary. */
73
+ export function safeParseIntentCreate(input) {
74
+ return v.safeParse(IntentCreateSchema, input);
75
+ }
76
+ /** Identifies recognized unsupported payment shapes without silently dropping their extra instructions. */
77
+ export function unsupportedIntentPaymentShape(input) {
78
+ if (!input || typeof input !== "object" || Array.isArray(input))
79
+ return undefined;
80
+ const record = input;
81
+ if (!["deposit", "withdrawal", "automatic_charge"].includes(String(record["type"])))
82
+ return undefined;
83
+ if (Object.hasOwn(record, "beneficiaries") || Array.isArray(record["beneficiary"]))
84
+ return "multiple_beneficiaries_not_implemented";
85
+ if (Object.hasOwn(record, "allocations") || Object.hasOwn(record, "split"))
86
+ return "split_payments_not_implemented";
87
+ if (Object.hasOwn(record, "instructions"))
88
+ return "multiple_instructions_not_implemented";
89
+ return undefined;
90
+ }
91
+ /** Values proposed by the account holder; the database enforces editability and freezes confirmation. */
92
+ export const WithdrawalConfirmationSchema = /* @__PURE__ */ v.strictObject({
93
+ intent_id: accountId,
94
+ source_account_id: v.optional(accountId),
95
+ amount: v.optional(amount.suggested),
96
+ beneficiary: v.optional(v.strictObject(bankAccount)),
97
+ note: v.optional(v.pipe(v.string(), v.trim(), v.check((value) => [...value].length <= 140, "note_too_long"))),
98
+ });
99
+ export function safeParseWithdrawalConfirmation(input) {
100
+ return v.safeParse(WithdrawalConfirmationSchema, input);
101
+ }
@@ -0,0 +1,12 @@
1
+ import * as v from "valibot";
2
+ /** Resolves or cancels a deferred authorization request from the hosted button. */
3
+ export declare const AndCoAuthorizationResponseMessageSchema: v.StrictObjectSchema<{
4
+ readonly type: v.LiteralSchema<"authorization-response", undefined>;
5
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
6
+ readonly authorizationUrl: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 8192, undefined>]>, undefined>;
7
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
8
+ readonly version: v.LiteralSchema<2, undefined>;
9
+ }, undefined>;
10
+ /** Host response containing a deferred authorization URL, or no URL when resolution failed. */
11
+ export type AndCoAuthorizationResponseMessage = v.InferOutput<typeof AndCoAuthorizationResponseMessageSchema>;
12
+ //# sourceMappingURL=authorization-response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-response.d.ts","sourceRoot":"","sources":["../../src/messages/authorization-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,mFAAmF;AACnF,eAAO,MAAM,uCAAuC;;;;;;aAKlD,CAAC;AACH,+FAA+F;AAC/F,MAAM,MAAM,iCAAiC,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,uCAAuC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import * as v from "valibot";
2
+ import { AndCoMessageBaseEntries, AndCoPresentationIdSchema } from "./base.js";
3
+ /** Resolves or cancels a deferred authorization request from the hosted button. */
4
+ export const AndCoAuthorizationResponseMessageSchema = /* @__PURE__ */ v.strictObject({
5
+ ...AndCoMessageBaseEntries,
6
+ type: v.literal("authorization-response"),
7
+ presentationId: AndCoPresentationIdSchema,
8
+ authorizationUrl: v.optional(v.pipe(v.string(), v.minLength(1), v.maxLength(8_192))),
9
+ });
@@ -0,0 +1,31 @@
1
+ import * as v from "valibot";
2
+ /** Base fields shared by every protocol message. */
3
+ export declare const AndCoMessageBaseEntries: {
4
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
5
+ readonly version: v.LiteralSchema<2, undefined>;
6
+ };
7
+ /** Identifier used to bind bridge messages to one authorization transaction. */
8
+ export declare const AndCoTransactionIdSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
9
+ /**
10
+ * Checks whether an unknown value is a valid AndCo transaction identifier.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * if (IS_ANDCO_TRANSACTION_ID(message.transactionId)) {
15
+ * // The identifier is safe to use for protocol correlation.
16
+ * }
17
+ * ```
18
+ */
19
+ export declare function IS_ANDCO_TRANSACTION_ID(input: unknown): input is string;
20
+ /** Identifier used to correlate one concrete popup presentation. */
21
+ export declare const AndCoPresentationIdSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
22
+ /** Checks whether an unknown value is a valid popup presentation identifier. */
23
+ export declare function IS_ANDCO_PRESENTATION_ID(input: unknown): input is string;
24
+ /** Common protocol fields included in every bridge message. */
25
+ export declare const AndCoMessageBaseSchema: v.StrictObjectSchema<{
26
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
27
+ readonly version: v.LiteralSchema<2, undefined>;
28
+ }, undefined>;
29
+ /** Message containing the shared protocol fields. */
30
+ export type AndCoMessageBase = v.InferOutput<typeof AndCoMessageBaseSchema>;
31
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/messages/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,oDAAoD;AACpD,eAAO,MAAM,uBAAuB;;;CAG1B,CAAC;AAEX,gFAAgF;AAChF,eAAO,MAAM,wBAAwB,8KAKpC,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEvE;AAED,oEAAoE;AACpE,eAAO,MAAM,yBAAyB,8KAKrC,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExE;AAED,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB;;;aAA0D,CAAC;AAC9F,qDAAqD;AACrD,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import * as v from "valibot";
2
+ import { ANDCO_PROTOCOL_VERSION, ANDCO_SDK_PROTOCOL } from "../constants.js";
3
+ /** Base fields shared by every protocol message. */
4
+ export const AndCoMessageBaseEntries = {
5
+ protocol: v.literal(ANDCO_SDK_PROTOCOL),
6
+ version: v.literal(ANDCO_PROTOCOL_VERSION),
7
+ };
8
+ /** Identifier used to bind bridge messages to one authorization transaction. */
9
+ export const AndCoTransactionIdSchema = /* @__PURE__ */ v.pipe(v.string(), v.minLength(1), v.maxLength(128), v.regex(/^[A-Za-z0-9_-]+$/));
10
+ /**
11
+ * Checks whether an unknown value is a valid AndCo transaction identifier.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * if (IS_ANDCO_TRANSACTION_ID(message.transactionId)) {
16
+ * // The identifier is safe to use for protocol correlation.
17
+ * }
18
+ * ```
19
+ */
20
+ export function IS_ANDCO_TRANSACTION_ID(input) {
21
+ return v.safeParse(AndCoTransactionIdSchema, input).success;
22
+ }
23
+ /** Identifier used to correlate one concrete popup presentation. */
24
+ export const AndCoPresentationIdSchema = /* @__PURE__ */ v.pipe(v.string(), v.minLength(1), v.maxLength(128), v.regex(/^[A-Za-z0-9_-]+$/));
25
+ /** Checks whether an unknown value is a valid popup presentation identifier. */
26
+ export function IS_ANDCO_PRESENTATION_ID(input) {
27
+ return v.safeParse(AndCoPresentationIdSchema, input).success;
28
+ }
29
+ /** Common protocol fields included in every bridge message. */
30
+ export const AndCoMessageBaseSchema = /* @__PURE__ */ v.strictObject(AndCoMessageBaseEntries);
@@ -0,0 +1,11 @@
1
+ import * as v from "valibot";
2
+ /** The secure button was activated. This is not a completed financial operation. */
3
+ export declare const AndCoClickEventSchema: v.StrictObjectSchema<{
4
+ readonly type: v.LiteralSchema<"click", undefined>;
5
+ readonly presentationId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>, undefined>;
6
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
7
+ readonly version: v.LiteralSchema<2, undefined>;
8
+ }, undefined>;
9
+ /** Event emitted when the secure button is activated. */
10
+ export type AndCoClickEvent = v.InferOutput<typeof AndCoClickEventSchema>;
11
+ //# sourceMappingURL=click.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/messages/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,oFAAoF;AACpF,eAAO,MAAM,qBAAqB;;;;;aAIhC,CAAC;AACH,yDAAyD;AACzD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import * as v from "valibot";
2
+ import { AndCoMessageBaseEntries, AndCoPresentationIdSchema } from "./base.js";
3
+ /** The secure button was activated. This is not a completed financial operation. */
4
+ export const AndCoClickEventSchema = /* @__PURE__ */ v.strictObject({
5
+ ...AndCoMessageBaseEntries,
6
+ type: v.literal("click"),
7
+ presentationId: v.optional(AndCoPresentationIdSchema),
8
+ });
@@ -0,0 +1,13 @@
1
+ import * as v from "valibot";
2
+ import { ANDCO_ERROR_CODES } from "../errors.js";
3
+ export declare const AndCoErrorEventSchema: v.StrictObjectSchema<{
4
+ readonly type: v.LiteralSchema<"error", undefined>;
5
+ readonly error: v.StrictObjectSchema<{
6
+ readonly code: v.PicklistSchema<[ANDCO_ERROR_CODES, ...ANDCO_ERROR_CODES[]], undefined>;
7
+ }, undefined>;
8
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
9
+ readonly version: v.LiteralSchema<2, undefined>;
10
+ }, undefined>;
11
+ /** Event emitted when the button or bridge detects an error. */
12
+ export type AndCoErrorEvent = v.InferOutput<typeof AndCoErrorEventSchema>;
13
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/messages/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAOjD,eAAO,MAAM,qBAAqB;;;;;;;aAIhC,CAAC;AACH,gEAAgE;AAChE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import * as v from "valibot";
2
+ import { ANDCO_ERROR_CODES } from "../errors.js";
3
+ import { AndCoMessageBaseEntries } from "./base.js";
4
+ const AndCoErrorCodeSchema = /* @__PURE__ */ v.picklist(Object.values(ANDCO_ERROR_CODES));
5
+ export const AndCoErrorEventSchema = /* @__PURE__ */ v.strictObject({
6
+ ...AndCoMessageBaseEntries,
7
+ type: v.literal("error"),
8
+ error: v.strictObject({ code: AndCoErrorCodeSchema }),
9
+ });
@@ -0,0 +1,75 @@
1
+ import * as v from "valibot";
2
+ /** Schema for every valid message sent through the AndCo bridge. */
3
+ export declare const AndCoBridgeMessageSchema: v.VariantSchema<"type", [v.StrictObjectSchema<{
4
+ readonly type: v.LiteralSchema<"authorization-response", undefined>;
5
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
6
+ readonly authorizationUrl: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 8192, undefined>]>, undefined>;
7
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
8
+ readonly version: v.LiteralSchema<2, undefined>;
9
+ }, undefined>, v.StrictObjectSchema<{
10
+ readonly type: v.LiteralSchema<"ready", undefined>;
11
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
12
+ readonly version: v.LiteralSchema<2, undefined>;
13
+ }, undefined>, v.StrictObjectSchema<{
14
+ readonly type: v.LiteralSchema<"click", undefined>;
15
+ readonly presentationId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>, undefined>;
16
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
17
+ readonly version: v.LiteralSchema<2, undefined>;
18
+ }, undefined>, v.StrictObjectSchema<{
19
+ readonly type: v.LiteralSchema<"error", undefined>;
20
+ readonly error: v.StrictObjectSchema<{
21
+ readonly code: v.PicklistSchema<[import("../errors.js").ANDCO_ERROR_CODES, ...import("../errors.js").ANDCO_ERROR_CODES[]], undefined>;
22
+ }, undefined>;
23
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
24
+ readonly version: v.LiteralSchema<2, undefined>;
25
+ }, undefined>, v.StrictObjectSchema<{
26
+ readonly type: v.LiteralSchema<"init", undefined>;
27
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
28
+ readonly version: v.LiteralSchema<2, undefined>;
29
+ }, undefined>, v.StrictObjectSchema<{
30
+ readonly type: v.LiteralSchema<"set-preferences", undefined>;
31
+ readonly themeMode: v.OptionalSchema<v.PicklistSchema<["dark", "light", "system"], undefined>, undefined>;
32
+ readonly locale: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 35, undefined>, v.CheckAction<string, undefined>]>, undefined>;
33
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
34
+ readonly version: v.LiteralSchema<2, undefined>;
35
+ }, undefined>, v.StrictObjectSchema<{
36
+ readonly type: v.LiteralSchema<"oauth.authorization_code", undefined>;
37
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
38
+ readonly authorizationCode: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 8192, undefined>]>;
39
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
40
+ readonly version: v.LiteralSchema<2, undefined>;
41
+ }, undefined>, v.StrictObjectSchema<{
42
+ readonly type: v.LiteralSchema<"oauth.complete", undefined>;
43
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
44
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
45
+ readonly version: v.LiteralSchema<2, undefined>;
46
+ }, undefined>, v.StrictObjectSchema<{
47
+ readonly type: v.LiteralSchema<"oauth.dismiss", undefined>;
48
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
49
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
50
+ readonly version: v.LiteralSchema<2, undefined>;
51
+ }, undefined>, v.StrictObjectSchema<{
52
+ readonly type: v.LiteralSchema<"oauth.error", undefined>;
53
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
54
+ readonly error: v.StrictObjectSchema<{
55
+ readonly code: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 256, undefined>]>;
56
+ readonly description: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 2048, undefined>]>, undefined>;
57
+ }, undefined>;
58
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
59
+ readonly version: v.LiteralSchema<2, undefined>;
60
+ }, undefined>, v.ObjectSchema<{
61
+ readonly type: v.LiteralSchema<"intent.complete", undefined>;
62
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
63
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
64
+ readonly version: v.LiteralSchema<2, undefined>;
65
+ }, undefined>, v.ObjectSchema<{
66
+ readonly type: v.LiteralSchema<"intent.dismiss", undefined>;
67
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
68
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
69
+ readonly version: v.LiteralSchema<2, undefined>;
70
+ }, undefined>], undefined>;
71
+ /** Union of every valid AndCo bridge message. */
72
+ export type AndCoBridgeMessage = v.InferOutput<typeof AndCoBridgeMessageSchema>;
73
+ /** Checks whether an unknown value is a valid AndCo bridge message. */
74
+ export declare function isAndCoBridgeMessage(input: unknown): input is AndCoBridgeMessage;
75
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAgB7B,oEAAoE;AACpE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAanC,CAAC;AACH,iDAAiD;AACjD,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF,uEAAuE;AACvE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAEhF"}
@@ -0,0 +1,27 @@
1
+ import * as v from "valibot";
2
+ import { AndCoAuthorizationResponseMessageSchema } from "./authorization-response.js";
3
+ import { AndCoClickEventSchema } from "./click.js";
4
+ import { AndCoErrorEventSchema } from "./error.js";
5
+ import { AndCoInitMessageSchema } from "./init.js";
6
+ import { AndCoIntentCompleteEventSchema, AndCoIntentDismissEventSchema, AndCoOAuthAuthorizationCodeEventSchema, AndCoOAuthCompleteEventSchema, AndCoOAuthDismissEventSchema, AndCoOAuthErrorEventSchema, } from "./popup.js";
7
+ import { AndCoReadyEventSchema } from "./ready.js";
8
+ import { AndCoSetPreferencesMessageSchema } from "./set-preferences.js";
9
+ /** Schema for every valid message sent through the AndCo bridge. */
10
+ export const AndCoBridgeMessageSchema = /* @__PURE__ */ v.variant("type", [
11
+ AndCoAuthorizationResponseMessageSchema,
12
+ AndCoReadyEventSchema,
13
+ AndCoClickEventSchema,
14
+ AndCoErrorEventSchema,
15
+ AndCoInitMessageSchema,
16
+ AndCoSetPreferencesMessageSchema,
17
+ AndCoOAuthAuthorizationCodeEventSchema,
18
+ AndCoOAuthCompleteEventSchema,
19
+ AndCoOAuthDismissEventSchema,
20
+ AndCoOAuthErrorEventSchema,
21
+ AndCoIntentCompleteEventSchema,
22
+ AndCoIntentDismissEventSchema,
23
+ ]);
24
+ /** Checks whether an unknown value is a valid AndCo bridge message. */
25
+ export function isAndCoBridgeMessage(input) {
26
+ return v.safeParse(AndCoBridgeMessageSchema, input).success;
27
+ }
@@ -0,0 +1,9 @@
1
+ import * as v from "valibot";
2
+ export declare const AndCoInitMessageSchema: v.StrictObjectSchema<{
3
+ readonly type: v.LiteralSchema<"init", undefined>;
4
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
5
+ readonly version: v.LiteralSchema<2, undefined>;
6
+ }, undefined>;
7
+ /** Message used by the host to start the bridge handshake. */
8
+ export type AndCoInitMessage = v.InferOutput<typeof AndCoInitMessageSchema>;
9
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/messages/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,eAAO,MAAM,sBAAsB;;;;aAGjC,CAAC;AACH,8DAA8D;AAC9D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import * as v from "valibot";
2
+ import { AndCoMessageBaseEntries } from "./base.js";
3
+ export const AndCoInitMessageSchema = /* @__PURE__ */ v.strictObject({
4
+ ...AndCoMessageBaseEntries,
5
+ type: v.literal("init"),
6
+ });
@@ -0,0 +1,108 @@
1
+ import * as v from "valibot";
2
+ /** Public OAuth authorization completed in a popup and returned a one-time code. */
3
+ export declare const AndCoOAuthAuthorizationCodeEventSchema: v.StrictObjectSchema<{
4
+ readonly type: v.LiteralSchema<"oauth.authorization_code", undefined>;
5
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
6
+ readonly authorizationCode: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 8192, undefined>]>;
7
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
8
+ readonly version: v.LiteralSchema<2, undefined>;
9
+ }, undefined>;
10
+ /** Public OAuth authorization code returned by a trusted callback page. */
11
+ export type AndCoOAuthAuthorizationCodeEvent = v.InferOutput<typeof AndCoOAuthAuthorizationCodeEventSchema>;
12
+ /** Host-managed OAuth authorization completed without exposing credentials. */
13
+ export declare const AndCoOAuthCompleteEventSchema: v.StrictObjectSchema<{
14
+ readonly type: v.LiteralSchema<"oauth.complete", undefined>;
15
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
16
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
17
+ readonly version: v.LiteralSchema<2, undefined>;
18
+ }, undefined>;
19
+ /** Host-managed OAuth completion returned by a trusted callback page. */
20
+ export type AndCoOAuthCompleteEvent = v.InferOutput<typeof AndCoOAuthCompleteEventSchema>;
21
+ /** OAuth authorization was dismissed or denied in a popup. */
22
+ export declare const AndCoOAuthDismissEventSchema: v.StrictObjectSchema<{
23
+ readonly type: v.LiteralSchema<"oauth.dismiss", undefined>;
24
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
25
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
26
+ readonly version: v.LiteralSchema<2, undefined>;
27
+ }, undefined>;
28
+ /** OAuth dismissal returned by a trusted callback page. */
29
+ export type AndCoOAuthDismissEvent = v.InferOutput<typeof AndCoOAuthDismissEventSchema>;
30
+ /** An Intent completed in a popup. */
31
+ export declare const AndCoIntentCompleteEventSchema: v.ObjectSchema<{
32
+ readonly type: v.LiteralSchema<"intent.complete", undefined>;
33
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
34
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
35
+ readonly version: v.LiteralSchema<2, undefined>;
36
+ }, undefined>;
37
+ /** Intent completion returned by its trusted presentation page. */
38
+ export type AndCoIntentCompleteEvent = v.InferOutput<typeof AndCoIntentCompleteEventSchema>;
39
+ /** An Intent was dismissed in a popup. */
40
+ export declare const AndCoIntentDismissEventSchema: v.ObjectSchema<{
41
+ readonly type: v.LiteralSchema<"intent.dismiss", undefined>;
42
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
43
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
44
+ readonly version: v.LiteralSchema<2, undefined>;
45
+ }, undefined>;
46
+ /** Intent dismissal returned by its trusted presentation page. */
47
+ export type AndCoIntentDismissEvent = v.InferOutput<typeof AndCoIntentDismissEventSchema>;
48
+ /**
49
+ * OAuth authorization ended in a protocol error rather than a decision.
50
+ *
51
+ * Kept apart from `oauth.dismiss` on purpose: a dismissal says the user declined, and reporting
52
+ * `server_error` or `invalid_scope` that way invents a decision nobody made. The code is an OAuth
53
+ * error identifier from RFC 6749, so it is a free string rather than one of our own codes.
54
+ */
55
+ export declare const AndCoOAuthErrorEventSchema: v.StrictObjectSchema<{
56
+ readonly type: v.LiteralSchema<"oauth.error", undefined>;
57
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
58
+ readonly error: v.StrictObjectSchema<{
59
+ readonly code: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 256, undefined>]>;
60
+ readonly description: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 2048, undefined>]>, undefined>;
61
+ }, undefined>;
62
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
63
+ readonly version: v.LiteralSchema<2, undefined>;
64
+ }, undefined>;
65
+ /** OAuth error returned by a trusted callback page. */
66
+ export type AndCoOAuthErrorEvent = v.InferOutput<typeof AndCoOAuthErrorEventSchema>;
67
+ /** Every valid result that a popup callback may return to its opener. */
68
+ export declare const AndCoPopupResultSchema: v.VariantSchema<"type", [v.StrictObjectSchema<{
69
+ readonly type: v.LiteralSchema<"oauth.authorization_code", undefined>;
70
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
71
+ readonly authorizationCode: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 8192, undefined>]>;
72
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
73
+ readonly version: v.LiteralSchema<2, undefined>;
74
+ }, undefined>, v.StrictObjectSchema<{
75
+ readonly type: v.LiteralSchema<"oauth.complete", undefined>;
76
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
77
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
78
+ readonly version: v.LiteralSchema<2, undefined>;
79
+ }, undefined>, v.StrictObjectSchema<{
80
+ readonly type: v.LiteralSchema<"oauth.dismiss", undefined>;
81
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
82
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
83
+ readonly version: v.LiteralSchema<2, undefined>;
84
+ }, undefined>, v.StrictObjectSchema<{
85
+ readonly type: v.LiteralSchema<"oauth.error", undefined>;
86
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
87
+ readonly error: v.StrictObjectSchema<{
88
+ readonly code: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 256, undefined>]>;
89
+ readonly description: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 2048, undefined>]>, undefined>;
90
+ }, undefined>;
91
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
92
+ readonly version: v.LiteralSchema<2, undefined>;
93
+ }, undefined>, v.ObjectSchema<{
94
+ readonly type: v.LiteralSchema<"intent.complete", undefined>;
95
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
96
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
97
+ readonly version: v.LiteralSchema<2, undefined>;
98
+ }, undefined>, v.ObjectSchema<{
99
+ readonly type: v.LiteralSchema<"intent.dismiss", undefined>;
100
+ readonly presentationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, undefined>]>;
101
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
102
+ readonly version: v.LiteralSchema<2, undefined>;
103
+ }, undefined>], undefined>;
104
+ /** Result returned by a popup callback to its opener. */
105
+ export type AndCoPopupResult = v.InferOutput<typeof AndCoPopupResultSchema>;
106
+ /** Checks whether an unknown value is a valid popup result. */
107
+ export declare function isAndCoPopupResult(input: unknown): input is AndCoPopupResult;
108
+ //# sourceMappingURL=popup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popup.d.ts","sourceRoot":"","sources":["../../src/messages/popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,oFAAoF;AACpF,eAAO,MAAM,sCAAsC;;;;;;aAKjD,CAAC;AACH,2EAA2E;AAC3E,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,sCAAsC,CAAC,CAAC;AAE5G,+EAA+E;AAC/E,eAAO,MAAM,6BAA6B;;;;;aAIxC,CAAC;AACH,yEAAyE;AACzE,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAE1F,8DAA8D;AAC9D,eAAO,MAAM,4BAA4B;;;;;aAIvC,CAAC;AACH,2DAA2D;AAC3D,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAExF,sCAAsC;AACtC,eAAO,MAAM,8BAA8B;;;;;aAIzC,CAAC;AACH,mEAAmE;AACnE,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAE5F,0CAA0C;AAC1C,eAAO,MAAM,6BAA6B;;;;;aAIxC,CAAC;AACH,kEAAkE;AAClE,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAE1F;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;aAQrC,CAAC;AACH,uDAAuD;AACvD,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEpF,yEAAyE;AACzE,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAOjC,CAAC;AACH,yDAAyD;AACzD,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE5E,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E"}
@@ -0,0 +1,62 @@
1
+ import * as v from "valibot";
2
+ import { AndCoMessageBaseEntries, AndCoPresentationIdSchema } from "./base.js";
3
+ /** Public OAuth authorization completed in a popup and returned a one-time code. */
4
+ export const AndCoOAuthAuthorizationCodeEventSchema = /* @__PURE__ */ v.strictObject({
5
+ ...AndCoMessageBaseEntries,
6
+ type: v.literal("oauth.authorization_code"),
7
+ presentationId: AndCoPresentationIdSchema,
8
+ authorizationCode: v.pipe(v.string(), v.minLength(1), v.maxLength(8_192)),
9
+ });
10
+ /** Host-managed OAuth authorization completed without exposing credentials. */
11
+ export const AndCoOAuthCompleteEventSchema = /* @__PURE__ */ v.strictObject({
12
+ ...AndCoMessageBaseEntries,
13
+ type: v.literal("oauth.complete"),
14
+ presentationId: AndCoPresentationIdSchema,
15
+ });
16
+ /** OAuth authorization was dismissed or denied in a popup. */
17
+ export const AndCoOAuthDismissEventSchema = /* @__PURE__ */ v.strictObject({
18
+ ...AndCoMessageBaseEntries,
19
+ type: v.literal("oauth.dismiss"),
20
+ presentationId: AndCoPresentationIdSchema,
21
+ });
22
+ /** An Intent completed in a popup. */
23
+ export const AndCoIntentCompleteEventSchema = /* @__PURE__ */ v.object({
24
+ ...AndCoMessageBaseEntries,
25
+ type: v.literal("intent.complete"),
26
+ presentationId: AndCoPresentationIdSchema,
27
+ });
28
+ /** An Intent was dismissed in a popup. */
29
+ export const AndCoIntentDismissEventSchema = /* @__PURE__ */ v.object({
30
+ ...AndCoMessageBaseEntries,
31
+ type: v.literal("intent.dismiss"),
32
+ presentationId: AndCoPresentationIdSchema,
33
+ });
34
+ /**
35
+ * OAuth authorization ended in a protocol error rather than a decision.
36
+ *
37
+ * Kept apart from `oauth.dismiss` on purpose: a dismissal says the user declined, and reporting
38
+ * `server_error` or `invalid_scope` that way invents a decision nobody made. The code is an OAuth
39
+ * error identifier from RFC 6749, so it is a free string rather than one of our own codes.
40
+ */
41
+ export const AndCoOAuthErrorEventSchema = /* @__PURE__ */ v.strictObject({
42
+ ...AndCoMessageBaseEntries,
43
+ type: v.literal("oauth.error"),
44
+ presentationId: AndCoPresentationIdSchema,
45
+ error: v.strictObject({
46
+ code: v.pipe(v.string(), v.minLength(1), v.maxLength(256)),
47
+ description: v.optional(v.pipe(v.string(), v.maxLength(2_048))),
48
+ }),
49
+ });
50
+ /** Every valid result that a popup callback may return to its opener. */
51
+ export const AndCoPopupResultSchema = /* @__PURE__ */ v.variant("type", [
52
+ AndCoOAuthAuthorizationCodeEventSchema,
53
+ AndCoOAuthCompleteEventSchema,
54
+ AndCoOAuthDismissEventSchema,
55
+ AndCoOAuthErrorEventSchema,
56
+ AndCoIntentCompleteEventSchema,
57
+ AndCoIntentDismissEventSchema,
58
+ ]);
59
+ /** Checks whether an unknown value is a valid popup result. */
60
+ export function isAndCoPopupResult(input) {
61
+ return v.safeParse(AndCoPopupResultSchema, input).success;
62
+ }
@@ -0,0 +1,9 @@
1
+ import * as v from "valibot";
2
+ export declare const AndCoReadyEventSchema: v.StrictObjectSchema<{
3
+ readonly type: v.LiteralSchema<"ready", undefined>;
4
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
5
+ readonly version: v.LiteralSchema<2, undefined>;
6
+ }, undefined>;
7
+ /** Event emitted when the secure button is ready for interaction. */
8
+ export type AndCoReadyEvent = v.InferOutput<typeof AndCoReadyEventSchema>;
9
+ //# sourceMappingURL=ready.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ready.d.ts","sourceRoot":"","sources":["../../src/messages/ready.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,eAAO,MAAM,qBAAqB;;;;aAGhC,CAAC;AACH,qEAAqE;AACrE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import * as v from "valibot";
2
+ import { AndCoMessageBaseEntries } from "./base.js";
3
+ export const AndCoReadyEventSchema = /* @__PURE__ */ v.strictObject({
4
+ ...AndCoMessageBaseEntries,
5
+ type: v.literal("ready"),
6
+ });
@@ -0,0 +1,16 @@
1
+ import * as v from "valibot";
2
+ /** Colour-scheme preference for hosted AndCo surfaces. */
3
+ export declare const AndCoThemeModeSchema: v.PicklistSchema<["dark", "light", "system"], undefined>;
4
+ /** Colour-scheme preference for hosted AndCo surfaces. */
5
+ export type AndCoThemeMode = v.InferOutput<typeof AndCoThemeModeSchema>;
6
+ /** Visual preferences that a host can update without recreating the widget. */
7
+ export declare const AndCoSetPreferencesMessageSchema: v.StrictObjectSchema<{
8
+ readonly type: v.LiteralSchema<"set-preferences", undefined>;
9
+ readonly themeMode: v.OptionalSchema<v.PicklistSchema<["dark", "light", "system"], undefined>, undefined>;
10
+ readonly locale: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 35, undefined>, v.CheckAction<string, undefined>]>, undefined>;
11
+ readonly protocol: v.LiteralSchema<"andco:sdk", undefined>;
12
+ readonly version: v.LiteralSchema<2, undefined>;
13
+ }, undefined>;
14
+ /** Message used by the host to update non-authorization widget preferences. */
15
+ export type AndCoSetPreferencesMessage = v.InferOutput<typeof AndCoSetPreferencesMessageSchema>;
16
+ //# sourceMappingURL=set-preferences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-preferences.d.ts","sourceRoot":"","sources":["../../src/messages/set-preferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAgB7B,0DAA0D;AAC1D,eAAO,MAAM,oBAAoB,0DAA0D,CAAC;AAC5F,0DAA0D;AAC1D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,+EAA+E;AAC/E,eAAO,MAAM,gCAAgC;;;;;;aAK3C,CAAC;AACH,+EAA+E;AAC/E,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gCAAgC,CAAC,CAAC"}