@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,110 @@
1
+ import { ANDCO_NATIVE_MONEY, ANDCO_NATIVE_TEXT as t } from "./native-copy.js";
2
+ const SCOPE_LABELS = {
3
+ openid: "Identidad OpenID",
4
+ email: "Correo electrónico",
5
+ profile: "Nombre y avatar",
6
+ "profile:write": "Actualizar nombre y avatar",
7
+ "identities:read": "Leer identidades y documentos",
8
+ "addresses:read": "Leer direcciones",
9
+ "addresses:write": "Crear y actualizar direcciones",
10
+ "organizations:list": "Listar los nombres e identificadores de mis organizaciones",
11
+ "bank_accounts:read": "Leer cuentas bancarias",
12
+ "bank_accounts.movements:read": "Leer movimientos de cuentas bancarias",
13
+ };
14
+ /**
15
+ * Whether a Scope's checkbox may not be cleared: the Client's Scope Policy requires it, or an
16
+ * active OAuth Grant on this Connection already covers it and clearing the box would promise a
17
+ * revocation the system does not perform (ADR 0040). Exported so every consent surface -- web and
18
+ * the three native Hosts -- reads the same fact instead of re-deriving it.
19
+ */
20
+ export function ANDCO_CONSENT_SCOPE_IS_LOCKED(scope) {
21
+ return scope.mode === "required" || scope.grantedAt !== null;
22
+ }
23
+ /** Localized Platform label, falling back to provider-owned copy for custom scopes. */
24
+ export function ANDCO_CONSENT_SCOPES(consent, locale = "es") {
25
+ return consent.scopes.map((policy) => {
26
+ const label = SCOPE_LABELS[policy.scope];
27
+ return {
28
+ ...policy,
29
+ title: label ? t(label, {}, locale) : (policy.scopeDescription ?? policy.scope),
30
+ description: label ? undefined : policy.resourceServerName,
31
+ required: policy.mode === "required",
32
+ default: policy.mode === "default",
33
+ // `optional` starts unchecked on a brand-new Connection (ADR 0040's "genuine consent"
34
+ // default), but pre-checks -- still clearable, see ANDCO_CONSENT_SCOPE_IS_LOCKED below --
35
+ // once the Subject already has an active Grant on this Connection: a step-up authorization
36
+ // on an already-connected Client, not the person's first-ever encounter with it. See ADR 0041.
37
+ initial: policy.mode !== "optional" || policy.grantedAt !== null || policy.connectionHasPriorGrant,
38
+ // Whether the checkbox may not be cleared. When both `required` and `grantedAt` hold, the
39
+ // Client's policy is the reason it can't be dropped -- surfaces render "Required" over
40
+ // "Granted on <date>" by checking `required` before `grantedAt`; this module states the two
41
+ // facts and leaves that precedence to each surface's own copy.
42
+ locked: ANDCO_CONSENT_SCOPE_IS_LOCKED(policy),
43
+ };
44
+ });
45
+ }
46
+ /** Initializes the starting selection: required/default permissions, plus anything already granted. */
47
+ export function ANDCO_CONSENT_INITIAL_SCOPES(consent) {
48
+ return new Set(consent.scopes
49
+ .filter((scope) => scope.mode !== "optional" || scope.grantedAt !== null || scope.connectionHasPriorGrant)
50
+ .map((scope) => scope.scope));
51
+ }
52
+ /** Whether the in-progress selection is complete enough to submit; the server still authorizes on submit. */
53
+ export function ANDCO_CONSENT_CAN_SUBMIT(consent, scopes, bankAccountId, chargeSourceIds = []) {
54
+ return (!consent.organizationSelection &&
55
+ (scopes.size > 0 || Boolean(consent.resourceAuthorization) || Boolean(consent.chargeAuthorization)) &&
56
+ (!consent.resourceAuthorization || consent.resourceAuthorization.allowed) &&
57
+ (!consent.bankAccountAuthorization ||
58
+ consent.bankAccountAuthorization.accounts.some((a) => a.bankAccountId === bankAccountId)) &&
59
+ (!consent.chargeAuthorization ||
60
+ (chargeSourceIds.length >= (consent.chargeAuthorization.request.selection?.min ?? 1) &&
61
+ chargeSourceIds.length <= (consent.chargeAuthorization.request.selection?.max ?? 1) &&
62
+ new Set(chargeSourceIds).size === chargeSourceIds.length &&
63
+ chargeSourceIds.every((id) => consent.chargeAuthorization?.accounts.some((account) => account.id === id)))) &&
64
+ consent.scopes.every((scope) => scope.mode !== "required" || scopes.has(scope.scope)));
65
+ }
66
+ const INTERVAL_UNIT_LABELS = { days: "días", months: "meses", years: "años" };
67
+ /** Presents the same charge restrictions in both native renderers. */
68
+ export function ANDCO_CHARGE_SUMMARY(charge, locale = "es") {
69
+ const d = charge.request;
70
+ const money = (value) => ANDCO_NATIVE_MONEY(value, locale);
71
+ const tt = (text, values) => t(text, values, locale);
72
+ const budget = d.budget;
73
+ return [
74
+ { label: tt("Empresa seleccionada"), value: charge.companyName },
75
+ {
76
+ label: tt("Monto por cargo"),
77
+ value: d.transaction.minimum === d.transaction.maximum
78
+ ? `${money(d.transaction.minimum)} CLP`
79
+ : tt("{{min}} a {{max}}", { min: money(d.transaction.minimum), max: money(d.transaction.maximum) }),
80
+ },
81
+ {
82
+ label: tt("Empresa que recibe"),
83
+ value: `${charge.operatorName}. ${d.beneficiaries?.length
84
+ ? d.beneficiaries.join(", ")
85
+ : tt("Cuentas actuales y futuras de esta empresa operadora.")}`,
86
+ },
87
+ {
88
+ label: tt("Presupuesto acumulado configurado"),
89
+ value: budget
90
+ ? `${money(budget.amount)} / ${budget.interval.count} ${tt(INTERVAL_UNIT_LABELS[budget.interval.unit])} · ${budget.time_zone}`
91
+ : tt("Sin límite acumulado"),
92
+ },
93
+ {
94
+ label: tt("Permisos de cargos automáticos"),
95
+ value: tt("La aplicación podrá iniciar cargos con estas condiciones, sin pedirte autorización en cada ocasión."),
96
+ },
97
+ {
98
+ label: tt("Solicitante"),
99
+ value: tt("Los fondos y la autorización pertenecen a {{company}}. Tu participación queda registrada como solicitante; no se usará tu cuenta personal.", { company: charge.companyName }),
100
+ },
101
+ {
102
+ label: tt("Presupuesto acumulado configurado"),
103
+ value: charge.budgetAnchor
104
+ ? tt("Inicio conservado: {{date}}", {
105
+ date: new Date(charge.budgetAnchor).toLocaleString(locale, { timeZone: budget?.time_zone }),
106
+ })
107
+ : tt("El período comienza al autorizar por primera vez, no al inicio del mes."),
108
+ },
109
+ ];
110
+ }
@@ -0,0 +1,17 @@
1
+ /** Protocol identifier used by the AndCo bridge. */
2
+ export declare const ANDCO_SDK_PROTOCOL: "andco:sdk";
3
+ /** Current version of the AndCo message protocol. */
4
+ export declare const ANDCO_PROTOCOL_VERSION: 2;
5
+ /** Default origin of the AndCo Authorization Server. */
6
+ export declare const ANDCO_AUTH_ORIGIN: "https://auth.andco.cl";
7
+ /** Default origin of the AndCo application API. */
8
+ export declare const ANDCO_API_ORIGIN: "https://api.andco.cl";
9
+ /** Default origin serving the hosted AndCo surfaces embedded by widgets. */
10
+ export declare const ANDCO_WIDGET_ORIGIN: "https://widgets.andco.cl";
11
+ /** Current explicit version of the AndCo OAuth resource API. */
12
+ export declare const ANDCO_OAUTH_API_VERSION: "1788459778";
13
+ /** Returns the base URL for one OAuth resource API version. `_` resolves to the latest version. */
14
+ export declare function ANDCO_OAUTH_API_URL(endpoint: string | URL, version?: string | number): string;
15
+ /** Returns the versioned OAuth UserInfo endpoint for an AndCo API origin. `_` resolves to the latest version. */
16
+ export declare function ANDCO_OAUTH_USERINFO_URL(endpoint: string | URL, version?: string): string;
17
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,eAAO,MAAM,kBAAkB,EAAG,WAAoB,CAAC;AACvD,qDAAqD;AACrD,eAAO,MAAM,sBAAsB,EAAG,CAAU,CAAC;AACjD,wDAAwD;AACxD,eAAO,MAAM,iBAAiB,EAAG,uBAAgC,CAAC;AAClE,mDAAmD;AACnD,eAAO,MAAM,gBAAgB,EAAG,sBAA+B,CAAC;AAChE,4EAA4E;AAC5E,eAAO,MAAM,mBAAmB,EAAG,0BAAmC,CAAC;AACvE,gEAAgE;AAChE,eAAO,MAAM,uBAAuB,EAAG,YAAqB,CAAC;AAC7D,mGAAmG;AACnG,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,GAAE,MAAM,GAAG,MAAY,GAAG,MAAM,CAElG;AACD,iHAAiH;AACjH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,SAAM,GAAG,MAAM,CAEtF"}
@@ -0,0 +1,20 @@
1
+ /** Protocol identifier used by the AndCo bridge. */
2
+ export const ANDCO_SDK_PROTOCOL = "andco:sdk";
3
+ /** Current version of the AndCo message protocol. */
4
+ export const ANDCO_PROTOCOL_VERSION = 2;
5
+ /** Default origin of the AndCo Authorization Server. */
6
+ export const ANDCO_AUTH_ORIGIN = "https://auth.andco.cl";
7
+ /** Default origin of the AndCo application API. */
8
+ export const ANDCO_API_ORIGIN = "https://api.andco.cl";
9
+ /** Default origin serving the hosted AndCo surfaces embedded by widgets. */
10
+ export const ANDCO_WIDGET_ORIGIN = "https://widgets.andco.cl";
11
+ /** Current explicit version of the AndCo OAuth resource API. */
12
+ export const ANDCO_OAUTH_API_VERSION = "1788459778";
13
+ /** Returns the base URL for one OAuth resource API version. `_` resolves to the latest version. */
14
+ export function ANDCO_OAUTH_API_URL(endpoint, version = "_") {
15
+ return new URL(`/oauth/api/versions/${version}`, endpoint).href;
16
+ }
17
+ /** Returns the versioned OAuth UserInfo endpoint for an AndCo API origin. `_` resolves to the latest version. */
18
+ export function ANDCO_OAUTH_USERINFO_URL(endpoint, version = "_") {
19
+ return new URL(`${ANDCO_OAUTH_API_URL(endpoint, version)}/userinfo`).href;
20
+ }
@@ -0,0 +1,70 @@
1
+ /** Error codes produced by the SDK. */
2
+ export declare enum ANDCO_ERROR_CODES {
3
+ /** The current runtime does not provide the browser APIs required by the SDK. */
4
+ BROWSER_UNAVAILABLE = "BROWSER_UNAVAILABLE",
5
+ /** The user closed or cancelled the authorization flow before it completed. */
6
+ AUTH_CANCELLED = "AUTH_CANCELLED",
7
+ /** The authorization code could not be exchanged for a session. */
8
+ AUTH_EXCHANGE_FAILED = "AUTH_EXCHANGE_FAILED",
9
+ /** The authorization flow did not complete before its timeout elapsed. */
10
+ AUTH_TIMEOUT = "AUTH_TIMEOUT",
11
+ /** The configured authentication endpoint is invalid. */
12
+ INVALID_ENDPOINT_AUTH = "INVALID_ENDPOINT_AUTH",
13
+ /** The configured AndCo API endpoint is invalid. */
14
+ INVALID_ENDPOINT_API = "INVALID_ENDPOINT_API",
15
+ /** The configured button endpoint is invalid. */
16
+ INVALID_ENDPOINT_BUTTON = "INVALID_ENDPOINT_BUTTON",
17
+ /** The supplied iframe is missing or cannot be used by the SDK. */
18
+ INVALID_IFRAME = "INVALID_IFRAME",
19
+ /** The requested authentication mode is invalid. */
20
+ INVALID_AUTH_MODE = "INVALID_AUTH_MODE",
21
+ /** The configured public OAuth client identifier is invalid. */
22
+ INVALID_CLIENT_ID = "INVALID_CLIENT_ID",
23
+ /** The configured OAuth callback URL is invalid. */
24
+ INVALID_REDIRECT_TO = "INVALID_REDIRECT_TO",
25
+ /** A hosted-action callback could not be correlated with its original transaction. */
26
+ INVALID_CALLBACK = "INVALID_CALLBACK",
27
+ /** At least one requested permission scope is invalid. */
28
+ INVALID_SCOPE = "INVALID_SCOPE",
29
+ /** The configured SDK protocol version is invalid. */
30
+ INVALID_VERSION = "INVALID_VERSION",
31
+ /** The current runtime does not provide Fetch and none was configured. */
32
+ FETCH_UNAVAILABLE = "FETCH_UNAVAILABLE",
33
+ /** The browser prevented the SDK from opening the authorization popup. */
34
+ POPUP_BLOCKED = "POPUP_BLOCKED",
35
+ /** The SDK opened a popup but the browser refused to navigate it. */
36
+ POPUP_NAVIGATION_FAILED = "POPUP_NAVIGATION_FAILED",
37
+ /** A popup presentation did not settle before its bounded lifetime elapsed. */
38
+ POPUP_TIMEOUT = "POPUP_TIMEOUT",
39
+ /** A direct Intent popup requires an explicit callback URL. */
40
+ INTENT_CALLBACK_REQUIRED = "INTENT_CALLBACK_REQUIRED",
41
+ /** The button endpoint must not share the host application's origin. */
42
+ SAME_ORIGIN_ENDPOINT = "SAME_ORIGIN_ENDPOINT",
43
+ /** The requested authorization-flow presentation is not supported. */
44
+ UNSUPPORTED_PRESENTATION = "UNSUPPORTED_PRESENTATION",
45
+ /** The requested button theme is not supported. */
46
+ UNSUPPORTED_THEME = "UNSUPPORTED_THEME",
47
+ /** The requested color-scheme mode is not supported by the theme. */
48
+ UNSUPPORTED_THEME_MODE = "UNSUPPORTED_THEME_MODE",
49
+ /** An OAuth callback attempted to send credentials to an untrusted origin. */
50
+ UNTRUSTED_ORIGIN = "UNTRUSTED_ORIGIN",
51
+ /** The current runtime does not provide the Web Crypto capabilities required by the SDK. */
52
+ WEB_CRYPTO_UNAVAILABLE = "WEB_CRYPTO_UNAVAILABLE",
53
+ /** The iframe did not complete its secure handshake before the timeout elapsed. */
54
+ HANDSHAKE_TIMEOUT = "HANDSHAKE_TIMEOUT",
55
+ /** An unexpected error could not be mapped to a more specific SDK code. */
56
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
57
+ }
58
+ /** Error base class that preserves its prototype at runtime. */
59
+ export declare class ErrorExtendable extends Error {
60
+ constructor(message?: string, options?: ErrorOptions);
61
+ /** Checks whether a value is an instance of an error class. */
62
+ static is<T extends ErrorExtendable>(error: unknown, errorClass: new (...args: any[]) => T): error is T;
63
+ }
64
+ /** SDK-specific error that includes a code and optional context. */
65
+ export declare class AndCoSDKError extends ErrorExtendable {
66
+ readonly code: ANDCO_ERROR_CODES;
67
+ readonly payload: unknown;
68
+ constructor(code: ANDCO_ERROR_CODES, payload?: unknown, options?: ErrorOptions);
69
+ }
70
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,oBAAY,iBAAiB;IAC3B,iFAAiF;IACjF,mBAAmB,wBAAwB;IAC3C,+EAA+E;IAC/E,cAAc,mBAAmB;IACjC,mEAAmE;IACnE,oBAAoB,yBAAyB;IAC7C,0EAA0E;IAC1E,YAAY,iBAAiB;IAC7B,yDAAyD;IACzD,qBAAqB,0BAA0B;IAC/C,oDAAoD;IACpD,oBAAoB,yBAAyB;IAC7C,iDAAiD;IACjD,uBAAuB,4BAA4B;IACnD,mEAAmE;IACnE,cAAc,mBAAmB;IACjC,oDAAoD;IACpD,iBAAiB,sBAAsB;IACvC,gEAAgE;IAChE,iBAAiB,sBAAsB;IACvC,oDAAoD;IACpD,mBAAmB,wBAAwB;IAC3C,sFAAsF;IACtF,gBAAgB,qBAAqB;IACrC,0DAA0D;IAC1D,aAAa,kBAAkB;IAC/B,sDAAsD;IACtD,eAAe,oBAAoB;IACnC,0EAA0E;IAC1E,iBAAiB,sBAAsB;IACvC,0EAA0E;IAC1E,aAAa,kBAAkB;IAC/B,qEAAqE;IACrE,uBAAuB,4BAA4B;IACnD,+EAA+E;IAC/E,aAAa,kBAAkB;IAC/B,+DAA+D;IAC/D,wBAAwB,6BAA6B;IACrD,wEAAwE;IACxE,oBAAoB,yBAAyB;IAC7C,sEAAsE;IACtE,wBAAwB,6BAA6B;IACrD,mDAAmD;IACnD,iBAAiB,sBAAsB;IACvC,qEAAqE;IACrE,sBAAsB,2BAA2B;IACjD,8EAA8E;IAC9E,gBAAgB,qBAAqB;IACrC,4FAA4F;IAC5F,sBAAsB,2BAA2B;IACjD,mFAAmF;IACnF,iBAAiB,sBAAsB;IACvC,2EAA2E;IAC3E,aAAa,kBAAkB;CAChC;AAED,gEAAgE;AAChE,qBAAa,eAAgB,SAAQ,KAAK;gBACrB,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;IAM3D,+DAA+D;WACjD,EAAE,CAAC,CAAC,SAAS,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC;CAG/G;AAED,oEAAoE;AACpE,qBAAa,aAAc,SAAQ,eAAe;IAChD,SAAgB,IAAI,EAAE,iBAAiB,CAAC;IACxC,SAAgB,OAAO,EAAE,OAAO,CAAC;gBAEd,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY;CAKtF"}
package/dist/errors.js ADDED
@@ -0,0 +1,80 @@
1
+ /** Error codes produced by the SDK. */
2
+ export var ANDCO_ERROR_CODES;
3
+ (function (ANDCO_ERROR_CODES) {
4
+ /** The current runtime does not provide the browser APIs required by the SDK. */
5
+ ANDCO_ERROR_CODES["BROWSER_UNAVAILABLE"] = "BROWSER_UNAVAILABLE";
6
+ /** The user closed or cancelled the authorization flow before it completed. */
7
+ ANDCO_ERROR_CODES["AUTH_CANCELLED"] = "AUTH_CANCELLED";
8
+ /** The authorization code could not be exchanged for a session. */
9
+ ANDCO_ERROR_CODES["AUTH_EXCHANGE_FAILED"] = "AUTH_EXCHANGE_FAILED";
10
+ /** The authorization flow did not complete before its timeout elapsed. */
11
+ ANDCO_ERROR_CODES["AUTH_TIMEOUT"] = "AUTH_TIMEOUT";
12
+ /** The configured authentication endpoint is invalid. */
13
+ ANDCO_ERROR_CODES["INVALID_ENDPOINT_AUTH"] = "INVALID_ENDPOINT_AUTH";
14
+ /** The configured AndCo API endpoint is invalid. */
15
+ ANDCO_ERROR_CODES["INVALID_ENDPOINT_API"] = "INVALID_ENDPOINT_API";
16
+ /** The configured button endpoint is invalid. */
17
+ ANDCO_ERROR_CODES["INVALID_ENDPOINT_BUTTON"] = "INVALID_ENDPOINT_BUTTON";
18
+ /** The supplied iframe is missing or cannot be used by the SDK. */
19
+ ANDCO_ERROR_CODES["INVALID_IFRAME"] = "INVALID_IFRAME";
20
+ /** The requested authentication mode is invalid. */
21
+ ANDCO_ERROR_CODES["INVALID_AUTH_MODE"] = "INVALID_AUTH_MODE";
22
+ /** The configured public OAuth client identifier is invalid. */
23
+ ANDCO_ERROR_CODES["INVALID_CLIENT_ID"] = "INVALID_CLIENT_ID";
24
+ /** The configured OAuth callback URL is invalid. */
25
+ ANDCO_ERROR_CODES["INVALID_REDIRECT_TO"] = "INVALID_REDIRECT_TO";
26
+ /** A hosted-action callback could not be correlated with its original transaction. */
27
+ ANDCO_ERROR_CODES["INVALID_CALLBACK"] = "INVALID_CALLBACK";
28
+ /** At least one requested permission scope is invalid. */
29
+ ANDCO_ERROR_CODES["INVALID_SCOPE"] = "INVALID_SCOPE";
30
+ /** The configured SDK protocol version is invalid. */
31
+ ANDCO_ERROR_CODES["INVALID_VERSION"] = "INVALID_VERSION";
32
+ /** The current runtime does not provide Fetch and none was configured. */
33
+ ANDCO_ERROR_CODES["FETCH_UNAVAILABLE"] = "FETCH_UNAVAILABLE";
34
+ /** The browser prevented the SDK from opening the authorization popup. */
35
+ ANDCO_ERROR_CODES["POPUP_BLOCKED"] = "POPUP_BLOCKED";
36
+ /** The SDK opened a popup but the browser refused to navigate it. */
37
+ ANDCO_ERROR_CODES["POPUP_NAVIGATION_FAILED"] = "POPUP_NAVIGATION_FAILED";
38
+ /** A popup presentation did not settle before its bounded lifetime elapsed. */
39
+ ANDCO_ERROR_CODES["POPUP_TIMEOUT"] = "POPUP_TIMEOUT";
40
+ /** A direct Intent popup requires an explicit callback URL. */
41
+ ANDCO_ERROR_CODES["INTENT_CALLBACK_REQUIRED"] = "INTENT_CALLBACK_REQUIRED";
42
+ /** The button endpoint must not share the host application's origin. */
43
+ ANDCO_ERROR_CODES["SAME_ORIGIN_ENDPOINT"] = "SAME_ORIGIN_ENDPOINT";
44
+ /** The requested authorization-flow presentation is not supported. */
45
+ ANDCO_ERROR_CODES["UNSUPPORTED_PRESENTATION"] = "UNSUPPORTED_PRESENTATION";
46
+ /** The requested button theme is not supported. */
47
+ ANDCO_ERROR_CODES["UNSUPPORTED_THEME"] = "UNSUPPORTED_THEME";
48
+ /** The requested color-scheme mode is not supported by the theme. */
49
+ ANDCO_ERROR_CODES["UNSUPPORTED_THEME_MODE"] = "UNSUPPORTED_THEME_MODE";
50
+ /** An OAuth callback attempted to send credentials to an untrusted origin. */
51
+ ANDCO_ERROR_CODES["UNTRUSTED_ORIGIN"] = "UNTRUSTED_ORIGIN";
52
+ /** The current runtime does not provide the Web Crypto capabilities required by the SDK. */
53
+ ANDCO_ERROR_CODES["WEB_CRYPTO_UNAVAILABLE"] = "WEB_CRYPTO_UNAVAILABLE";
54
+ /** The iframe did not complete its secure handshake before the timeout elapsed. */
55
+ ANDCO_ERROR_CODES["HANDSHAKE_TIMEOUT"] = "HANDSHAKE_TIMEOUT";
56
+ /** An unexpected error could not be mapped to a more specific SDK code. */
57
+ ANDCO_ERROR_CODES["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
58
+ })(ANDCO_ERROR_CODES || (ANDCO_ERROR_CODES = {}));
59
+ /** Error base class that preserves its prototype at runtime. */
60
+ export class ErrorExtendable extends Error {
61
+ constructor(message, options) {
62
+ super(message, options);
63
+ Object.setPrototypeOf(this, new.target.prototype);
64
+ this.name = this.constructor.name;
65
+ }
66
+ /** Checks whether a value is an instance of an error class. */
67
+ static is(error, errorClass) {
68
+ return error instanceof errorClass;
69
+ }
70
+ }
71
+ /** SDK-specific error that includes a code and optional context. */
72
+ export class AndCoSDKError extends ErrorExtendable {
73
+ code;
74
+ payload;
75
+ constructor(code, payload, options) {
76
+ super(code, options);
77
+ this.code = code;
78
+ this.payload = payload;
79
+ }
80
+ }
@@ -0,0 +1,33 @@
1
+ export * from "./authorization.js";
2
+ export * from "./authorization-preparation.js";
3
+ export * from "./automatic-charge.js";
4
+ export * from "./bank-account-authorization.js";
5
+ export * from "./callback-state.js";
6
+ export * from "./consent.js";
7
+ export * from "./constants.js";
8
+ export * from "./errors.js";
9
+ export * from "./intent-input.js";
10
+ export * from "./messages/authorization-response.js";
11
+ export * from "./messages/base.js";
12
+ export * from "./messages/click.js";
13
+ export * from "./messages/error.js";
14
+ export * from "./messages/index.js";
15
+ export * from "./messages/init.js";
16
+ export * from "./messages/popup.js";
17
+ export * from "./messages/ready.js";
18
+ export * from "./messages/set-preferences.js";
19
+ export * from "./miniapp-icon.js";
20
+ export * from "./miniapp-manifest.js";
21
+ export * from "./native.js";
22
+ export * from "./native-copy.js";
23
+ export * from "./native-intent.js";
24
+ export * from "./oauth.js";
25
+ export * from "./release.js";
26
+ export * from "./scopes.js";
27
+ export * from "./urls.js";
28
+ export * from "./userinfo.js";
29
+ export * from "./utils.js";
30
+ export * from "./webhook-input.js";
31
+ export * from "./webhook-signature.js";
32
+ export { ANDCO_POPUP_NAME_PREFIX, type AndcoPopupGeometry, type AndcoPopupPosition, isBrowser, windowFeaturesFrom, } from "./window-features.js";
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sCAAsC,CAAC;AACrD,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAE3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,OAAO,EACL,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,SAAS,EACT,kBAAkB,GACnB,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ export * from "./authorization.js";
2
+ export * from "./authorization-preparation.js";
3
+ export * from "./automatic-charge.js";
4
+ export * from "./bank-account-authorization.js";
5
+ export * from "./callback-state.js";
6
+ export * from "./consent.js";
7
+ export * from "./constants.js";
8
+ export * from "./errors.js";
9
+ export * from "./intent-input.js";
10
+ export * from "./messages/authorization-response.js";
11
+ export * from "./messages/base.js";
12
+ export * from "./messages/click.js";
13
+ export * from "./messages/error.js";
14
+ export * from "./messages/index.js";
15
+ export * from "./messages/init.js";
16
+ export * from "./messages/popup.js";
17
+ export * from "./messages/ready.js";
18
+ export * from "./messages/set-preferences.js";
19
+ export * from "./miniapp-icon.js";
20
+ export * from "./miniapp-manifest.js";
21
+ export * from "./native.js";
22
+ export * from "./native-copy.js";
23
+ export * from "./native-intent.js";
24
+ export * from "./oauth.js";
25
+ export * from "./release.js";
26
+ export * from "./scopes.js";
27
+ export * from "./urls.js";
28
+ export * from "./userinfo.js";
29
+ export * from "./utils.js";
30
+ export * from "./webhook-input.js";
31
+ export * from "./webhook-signature.js";
32
+ export { ANDCO_POPUP_NAME_PREFIX, isBrowser, windowFeaturesFrom, } from "./window-features.js";